Fix local server for multiple applications
[anna.git] / example / diameter / launcher / resources / rest_api / ct / fsm-testing / test-next_test.py
1 import pytest
2
3
4 def test_001_i_want_to_launch_the_next_testcase_with_test_next(admlc, admlf):
5
6   flow = admlf.getId()
7
8   requestBody = { "amount":5 }
9   responseBodyRef = { "success":"true", "response":"Done" }
10
11   # Send POST
12   response = admlc.postDict("/testid-ip-limit/{}".format(flow), requestBody)
13
14   ## Launch the next
15   requestBody = {} # 1 by default
16   responseBodyRef = { "success":"true", "response":"Processed 1 test case" }
17   response = admlc.postDict("/test-next", requestBody)
18
19   # Verify response
20   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
21
22   # Cleanup
23   response = admlc.post("/test-clear")
24
25 def test_002_i_want_to_launch_a_bunch_of_tests_with_test_next(admlc, admlf):
26
27   flow1 = admlf.getId()
28   flow2 = admlf.getId()
29
30   requestBody = { "amount":5 }
31   responseBodyRef = { "success":"true", "response":"Done" }
32
33   # Send POSTs
34   response = admlc.postDict("/testid-ip-limit/{}".format(flow1), requestBody)
35   response = admlc.postDict("/testid-ip-limit/{}".format(flow2), requestBody)
36
37   ## Launch the second & third:
38   requestBody = { "syncAmount":2 }
39   responseBodyRef = { "success":"true", "response":"Processed 2 test cases synchronously" }
40   response = admlc.postDict("/test-next", requestBody)
41
42   # Verify response
43   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
44
45   # Cleanup
46   response = admlc.post("/test-clear")
47
48 @pytest.mark.skip(reason="pytest is quite fast and dedicated thread is still running on clear operation, so, clear is not completed")
49 def test_003_i_want_to_launch_the_next_testcase_with_test_next(admlc, admlf):
50
51   flow = admlf.getId()
52
53   requestBody = { "script":"date +'%s.%N'" }
54   responseBodyRef = { "success":"true", "response":"Done" }
55
56   # Send POST
57   response = admlc.postDict("/testid-sh-command/{}".format(flow), requestBody)
58
59   ## Launch the next
60   requestBody = {} # 1 by default
61   responseBodyRef = { "success":"true", "response":"Processed 1 test case" }
62   response = admlc.postDict("/test-next", requestBody)
63
64   # Verify response
65   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
66
67   # Cleanup
68   response = admlc.post("/test-clear")
69
70 @pytest.mark.skip(reason="pytest is quite fast and dedicated thread is still running on clear operation, so, clear is not completed")
71 def test_004_i_want_to_launch_a_bunch_of_tests_with_test_next(admlc, admlf):
72
73   flow1 = admlf.getId()
74   flow2 = admlf.getId()
75
76   requestBody = { "script":"date +'%s.%N'" }
77   responseBodyRef = { "success":"true", "response":"Done" }
78
79   # Send POSTs
80   response = admlc.postDict("/testid-sh-command/{}".format(flow1), requestBody)
81   response = admlc.postDict("/testid-sh-command/{}".format(flow2), requestBody)
82
83   ## Launch the second & third:
84   requestBody = { "syncAmount":2 }
85   responseBodyRef = { "success":"true", "response":"Processed 2 test cases synchronously" }
86   response = admlc.postDict("/test-next", requestBody)
87
88   # Verify response
89   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
90
91   # Cleanup
92   response = admlc.post("/test-clear")
93