X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fresources%2Frest_api%2Fct%2Fsnapshots%2Fcontext_test.py;fp=example%2Fdiameter%2Flauncher%2Fresources%2Frest_api%2Fct%2Fsnapshots%2Fcontext_test.py;h=1aa8b174dc420af07b5c030de326b86af00f5d30;hb=c881c12ed7e116f1d43760a0d9873f860c10a357;hp=0000000000000000000000000000000000000000;hpb=af14877201a9856708ec43086a229777d9cb3da7;p=anna.git diff --git a/example/diameter/launcher/resources/rest_api/ct/snapshots/context_test.py b/example/diameter/launcher/resources/rest_api/ct/snapshots/context_test.py new file mode 100644 index 0000000..1aa8b17 --- /dev/null +++ b/example/diameter/launcher/resources/rest_api/ct/snapshots/context_test.py @@ -0,0 +1,34 @@ +import pytest +import re + + +def test_001_given_a_target_file_i_want_to_dump_the_adml_context(admlc): + + requestBody = { "targetFile":"/tmp/context.xml" } + responseBodyRef = { "success":"true", "response":"Context dumped on file '/tmp/context.xml'" } + + # Send POST + response = admlc.postDict("/context", requestBody) + + # Verify response + admlc.assert_response__status_body_headers(response, 200, responseBodyRef) + +def test_002_missing_a_target_file_i_want_to_dump_the_adml_context_at_default_location(admlc, mylogger): + + requestBody = { "targetFile":"" } + responseBodyRef = { "success":"true", "response":"Context dumped on file '/tmp/context.xml'" } + + # Send POST + response = admlc.postDict("/context", requestBody) + + # Verify response is ok (omit response content because it is informative and have dynamic data (timing)): + assert response["status"] == 200 + assert response["body"]["success"] == "true" + + body_response = response["body"]["response"] + pattern = "Context dumped on file '/var/tmp/anna.context.[0-9]*'" + result = re.match(pattern, body_response) + if not result: + mylogger.error("Body response \"" + body_response + "\" does not match the pattern \"" + pattern + "\"") + + assert result