Add second work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / flow-operations / answermsg2e_test.py
diff --git a/example/diameter/launcher/resources/rest_api/ct/flow-operations/answermsg2e_test.py b/example/diameter/launcher/resources/rest_api/ct/flow-operations/answermsg2e_test.py
new file mode 100644 (file)
index 0000000..6f97b84
--- /dev/null
@@ -0,0 +1,80 @@
+import pytest
+
+
+def test_001_given_diameter_answer_json_representation_i_want_to_provision_it_to_reacts_to_diameter_entity_requests(resources, admlc):
+
+  requestBody = { "name":"afHost.afRealm.com" }
+  responseBodyRef = { "success":"true", "response":"Forced node is now 'afHost.afRealm.com'" }
+
+  # Send POST
+  response = admlc.postDict("/node", requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  requestBody = resources("aaa-diameterJson-request.json")
+  responseBodyRef = { "success":"true", "response":"Added 'answer to entity' to the FIFO queue corresponding to its message code" }
+
+  # Send POST
+  response = admlc.post("/answermsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+def test_002_i_want_to_list_the_answer_to_entity_FIFO_queue(b64_decode, mylogger, admlc):
+
+  requestBody = { "action":"list" } # also empty action is interpreted as "list"
+
+  # Send POST
+  response = admlc.postDict("/answermsg2e", requestBody)
+
+  # Verify response is ok (omit response content because it is dynamic: will be logged)
+  assert response["status"] == 200
+  assert response["body"]["success"] == "true"
+  body_response = b64_decode(response["body"]["response"])
+  mylogger.info("\nBASE64 DECODED RESPONSE: \n\n" + body_response)
+
+def test_003_i_want_to_dump_the_answer_to_entity_FIFO_queue(admlc):
+
+  requestBody = { "action":"dump" }
+  responseBodyRef = { "success":"true", "response":"dump" }
+
+  # Send POST
+  response = admlc.postDict("/answermsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+def test_004_i_want_to_clear_the_answer_to_entity_FIFO_queue(admlc):
+
+  requestBody = { "action":"clear" }
+  responseBodyRef = { "success":"true", "response":"clear" }
+
+  # Send POST
+  response = admlc.postDict("/answermsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+def test_005_i_want_to_exhaust_the_answer_to_entity_FIFO_queue(admlc):
+
+  requestBody = { "action":"exhaust" }
+  responseBodyRef = { "success":"true", "response":"exhaust" }
+
+  # Send POST
+  response = admlc.postDict("/answermsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+def test_006_i_want_to_rotate_the_answer_to_entity_FIFO_queue(admlc):
+
+  requestBody = { "action":"rotate" }
+  responseBodyRef = { "success":"true", "response":"rotate" }
+
+  # Send POST
+  response = admlc.postDict("/answermsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+