Add fourth work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / fsm-testing / test-run_test.py
1 import pytest
2
3
4 def test_001_i_want_to_run_specific_test(admlc, admlf):
5
6   # Send POST (test flow with a single step changing ip-limit to 15)
7   flow = admlf.getId()
8   response = admlc.postDict("/testid-ip-limit/{}".format(flow), { "amount":15 })
9
10   # Verify response (test & step programmed)
11   responseBodyRef = { "success":"true", "response":"Done" }
12   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
13
14   # Send POST (execute the former test)
15   response = admlc.postDict("/test-run", { "id":flow })
16
17   # Verify response
18   responseBodyRef = { "success":"true", "response":"Test executed for id provided ({})".format(flow) }
19   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
20
21   # Verify ip-limit now:
22   response = admlc.postDict("/test-ip-limit", {}) # default {} to query current state
23   responseBodyRef = { "success":"true", "response":"In-progress limit amount: 15; currently there are 0 test cases running" }
24   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
25
26   # Cleanup & restore ip-limit (at global level because it is easier)
27   response = admlc.post("/test-clear")
28   response = admlc.postDict("/test-ip-limit", { "amount":-1 })
29
30
31 def test_002_i_want_to_run_unexisting_test(admlc):
32
33   # Send POST
34   response = admlc.postDict("/test-run", { "id":666 })
35
36   # Verify response
37   responseBodyRef = { "success":"false", "response":"Internal error (check ADML traces): cannot found test id (666)" }
38   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
39