Add first work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / snapshots / context_test.py
1 import pytest
2 import re
3
4
5 def test_001_given_a_target_file_i_want_to_dump_the_adml_context(admlc):
6
7   requestBody = { "targetFile":"/tmp/context.xml" }
8   responseBodyRef = { "success":"true", "response":"Context dumped on file '/tmp/context.xml'" }
9
10   # Send POST
11   response = admlc.postDict("/context", requestBody)
12
13   # Verify response
14   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
15
16 def test_002_missing_a_target_file_i_want_to_dump_the_adml_context_at_default_location(admlc, mylogger):
17
18   requestBody = { "targetFile":"" }
19   responseBodyRef = { "success":"true", "response":"Context dumped on file '/tmp/context.xml'" }
20
21   # Send POST
22   response = admlc.postDict("/context", requestBody)
23
24   # Verify response is ok (omit response content because it is informative and have dynamic data (timing)):
25   assert response["status"] == 200
26   assert response["body"]["success"] == "true"
27
28   body_response = response["body"]["response"]
29   pattern = "Context dumped on file '/var/tmp/anna.context.[0-9]*'"
30   result = re.match(pattern, body_response)
31   if not result:
32     mylogger.error("Body response \"" + body_response + "\" does not match the pattern \"" + pattern + "\"")
33
34   assert result