Add second work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / flow-operations / answermsg2e_test.py
1 import pytest
2
3
4 def test_001_given_diameter_answer_json_representation_i_want_to_provision_it_to_reacts_to_diameter_entity_requests(resources, admlc):
5
6   requestBody = { "name":"afHost.afRealm.com" }
7   responseBodyRef = { "success":"true", "response":"Forced node is now 'afHost.afRealm.com'" }
8
9   # Send POST
10   response = admlc.postDict("/node", requestBody)
11
12   # Verify response
13   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
14
15   requestBody = resources("aaa-diameterJson-request.json")
16   responseBodyRef = { "success":"true", "response":"Added 'answer to entity' to the FIFO queue corresponding to its message code" }
17
18   # Send POST
19   response = admlc.post("/answermsg2e", requestBody)
20
21   ### Verify response
22   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
23
24 def test_002_i_want_to_list_the_answer_to_entity_FIFO_queue(b64_decode, mylogger, admlc):
25
26   requestBody = { "action":"list" } # also empty action is interpreted as "list"
27
28   # Send POST
29   response = admlc.postDict("/answermsg2e", requestBody)
30
31   # Verify response is ok (omit response content because it is dynamic: will be logged)
32   assert response["status"] == 200
33   assert response["body"]["success"] == "true"
34   body_response = b64_decode(response["body"]["response"])
35   mylogger.info("\nBASE64 DECODED RESPONSE: \n\n" + body_response)
36
37 def test_003_i_want_to_dump_the_answer_to_entity_FIFO_queue(admlc):
38
39   requestBody = { "action":"dump" }
40   responseBodyRef = { "success":"true", "response":"dump" }
41
42   # Send POST
43   response = admlc.postDict("/answermsg2e", requestBody)
44
45   ### Verify response
46   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
47
48 def test_004_i_want_to_clear_the_answer_to_entity_FIFO_queue(admlc):
49
50   requestBody = { "action":"clear" }
51   responseBodyRef = { "success":"true", "response":"clear" }
52
53   # Send POST
54   response = admlc.postDict("/answermsg2e", requestBody)
55
56   ### Verify response
57   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
58
59 def test_005_i_want_to_exhaust_the_answer_to_entity_FIFO_queue(admlc):
60
61   requestBody = { "action":"exhaust" }
62   responseBodyRef = { "success":"true", "response":"exhaust" }
63
64   # Send POST
65   response = admlc.postDict("/answermsg2e", requestBody)
66
67   ### Verify response
68   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
69
70 def test_006_i_want_to_rotate_the_answer_to_entity_FIFO_queue(admlc):
71
72   requestBody = { "action":"rotate" }
73   responseBodyRef = { "success":"true", "response":"rotate" }
74
75   # Send POST
76   response = admlc.postDict("/answermsg2e", requestBody)
77
78   ### Verify response
79   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
80