Add fourth work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / fsm-testing / test-next_test.py
diff --git a/example/diameter/launcher/resources/rest_api/ct/fsm-testing/test-next_test.py b/example/diameter/launcher/resources/rest_api/ct/fsm-testing/test-next_test.py
new file mode 100644 (file)
index 0000000..c9e6abf
--- /dev/null
@@ -0,0 +1,93 @@
+import pytest
+
+
+def test_001_i_want_to_launch_the_next_testcase_with_test_next(admlc, admlf):
+
+  flow = admlf.getId()
+
+  requestBody = { "amount":5 }
+  responseBodyRef = { "success":"true", "response":"Done" }
+
+  # Send POST
+  response = admlc.postDict("/testid-ip-limit/{}".format(flow), requestBody)
+
+  ## Launch the next
+  requestBody = {} # 1 by default
+  responseBodyRef = { "success":"true", "response":"Processed 1 test case" }
+  response = admlc.postDict("/test-next", requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")
+
+def test_002_i_want_to_launch_a_bunch_of_tests_with_test_next(admlc, admlf):
+
+  flow1 = admlf.getId()
+  flow2 = admlf.getId()
+
+  requestBody = { "amount":5 }
+  responseBodyRef = { "success":"true", "response":"Done" }
+
+  # Send POSTs
+  response = admlc.postDict("/testid-ip-limit/{}".format(flow1), requestBody)
+  response = admlc.postDict("/testid-ip-limit/{}".format(flow2), requestBody)
+
+  ## Launch the second & third:
+  requestBody = { "syncAmount":2 }
+  responseBodyRef = { "success":"true", "response":"Processed 2 test cases synchronously" }
+  response = admlc.postDict("/test-next", requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")
+
+@pytest.mark.skip(reason="pytest is quite fast and dedicated thread is still running on clear operation, so, clear is not completed")
+def test_003_i_want_to_launch_the_next_testcase_with_test_next(admlc, admlf):
+
+  flow = admlf.getId()
+
+  requestBody = { "script":"date +'%s.%N'" }
+  responseBodyRef = { "success":"true", "response":"Done" }
+
+  # Send POST
+  response = admlc.postDict("/testid-sh-command/{}".format(flow), requestBody)
+
+  ## Launch the next
+  requestBody = {} # 1 by default
+  responseBodyRef = { "success":"true", "response":"Processed 1 test case" }
+  response = admlc.postDict("/test-next", requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")
+
+@pytest.mark.skip(reason="pytest is quite fast and dedicated thread is still running on clear operation, so, clear is not completed")
+def test_004_i_want_to_launch_a_bunch_of_tests_with_test_next(admlc, admlf):
+
+  flow1 = admlf.getId()
+  flow2 = admlf.getId()
+
+  requestBody = { "script":"date +'%s.%N'" }
+  responseBodyRef = { "success":"true", "response":"Done" }
+
+  # Send POSTs
+  response = admlc.postDict("/testid-sh-command/{}".format(flow1), requestBody)
+  response = admlc.postDict("/testid-sh-command/{}".format(flow2), requestBody)
+
+  ## Launch the second & third:
+  requestBody = { "syncAmount":2 }
+  responseBodyRef = { "success":"true", "response":"Processed 2 test cases synchronously" }
+  response = admlc.postDict("/test-next", requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")
+