Add fourth work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / fsm-testing / test-goto_test.py
diff --git a/example/diameter/launcher/resources/rest_api/ct/fsm-testing/test-goto_test.py b/example/diameter/launcher/resources/rest_api/ct/fsm-testing/test-goto_test.py
new file mode 100644 (file)
index 0000000..5adea9a
--- /dev/null
@@ -0,0 +1,50 @@
+import pytest
+
+
+def test_001_i_want_to_move_to_specific_test_and_check_it(admlc, admlf):
+
+  # Send POST
+  flow = admlf.getId()
+  response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
+  flow = admlf.getId()
+  response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
+
+  # Verify response
+  responseBodyRef = { "success":"true", "response":"Done" }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Go to the second test:
+
+  # Send POST
+  response = admlc.postDict("/test-goto", { "id":flow })
+
+  # Verify response
+  responseBodyRef = { "success":"true", "response":"Position updated for id provided ({})".format(flow) }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")
+
+def test_002_i_want_to_move_to_a_test_out_of_range_and_check_it(admlc, admlf):
+
+  # Send POST
+  flow = admlf.getId()
+  response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
+  flow = admlf.getId()
+  response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
+
+  # Verify response
+  responseBodyRef = { "success":"true", "response":"Done" }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Go to the second test:
+
+  # Send POST
+  response = admlc.postDict("/test-goto", { "id":(flow+1) }) # flow+1 is out of range
+
+  # Verify response
+  responseBodyRef = { "success":"false", "response":"Internal error (check ADML traces): cannot found test id ({})".format(flow+1) }
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")