Add fourth work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / fsm-testing / test-goto_test.py
1 import pytest
2
3
4 def test_001_i_want_to_move_to_specific_test_and_check_it(admlc, admlf):
5
6   # Send POST
7   flow = admlf.getId()
8   response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
9   flow = admlf.getId()
10   response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
11
12   # Verify response
13   responseBodyRef = { "success":"true", "response":"Done" }
14   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
15
16   # Go to the second test:
17
18   # Send POST
19   response = admlc.postDict("/test-goto", { "id":flow })
20
21   # Verify response
22   responseBodyRef = { "success":"true", "response":"Position updated for id provided ({})".format(flow) }
23   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
24
25   # Cleanup
26   response = admlc.post("/test-clear")
27
28 def test_002_i_want_to_move_to_a_test_out_of_range_and_check_it(admlc, admlf):
29
30   # Send POST
31   flow = admlf.getId()
32   response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
33   flow = admlf.getId()
34   response = admlc.postDict("/testid-description/{}".format(flow), { "description":"testid-description.test_001.flow{}".format(flow) })
35
36   # Verify response
37   responseBodyRef = { "success":"true", "response":"Done" }
38   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
39
40   # Go to the second test:
41
42   # Send POST
43   response = admlc.postDict("/test-goto", { "id":(flow+1) }) # flow+1 is out of range
44
45   # Verify response
46   responseBodyRef = { "success":"false", "response":"Internal error (check ADML traces): cannot found test id ({})".format(flow+1) }
47   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
48
49   # Cleanup
50   response = admlc.post("/test-clear")