Add fourth work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / fsm-testing / test-interact_test.py
diff --git a/example/diameter/launcher/resources/rest_api/ct/fsm-testing/test-interact_test.py b/example/diameter/launcher/resources/rest_api/ct/fsm-testing/test-interact_test.py
new file mode 100644 (file)
index 0000000..d11086b
--- /dev/null
@@ -0,0 +1,46 @@
+import pytest
+
+
+def test_001_i_want_to_make_one_test_non_interactive(admlc, admlf):
+
+  # Send POST (test flow with a single step changing ip-limit to 15)
+  flow = admlf.getId()
+  response = admlc.postDict("/testid-ip-limit/{}".format(flow), { "amount":15 })
+
+  # Verify response (test & step programmed)
+  responseBodyRef = { "success":"true", "response":"Done" }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Send POST (execute the former test)
+  response = admlc.postDict("/test-interact", { "amount":-1, "id":flow })
+
+  # Verify response
+  responseBodyRef = { "success":"true", "response":"Interactive mode disabled for test case id {}".format(flow) }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup & restore ip-limit (at global level because it is easier)
+  response = admlc.post("/test-clear")
+  response = admlc.postDict("/test-ip-limit", { "amount":-1 })
+
+def test_002_i_want_to_freeze_a_test(admlc, admlf):
+
+  # Send POST (test flow with a single step changing ip-limit to 15)
+  flow = admlf.getId()
+  response = admlc.postDict("/testid-ip-limit/{}".format(flow), { "amount":15 })
+
+  # Verify response (test & step programmed)
+  responseBodyRef = { "success":"true", "response":"Done" }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Send POST (execute the former test)
+  response = admlc.postDict("/test-interact", { "amount":0, "id":flow })
+
+  # Verify response
+  respMsg = "Added interactive amount of 0 units (0: freezing a non-interactive testcase, no effect on already interactive) for test case id {}".format(flow)
+  responseBodyRef = { "success":"true", "response":respMsg }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup & restore ip-limit (at global level because it is easier)
+  response = admlc.post("/test-clear")
+  response = admlc.postDict("/test-ip-limit", { "amount":-1 })
+