Added helpers to pytest tests
[anna.git] / example / diameter / launcher / resources / rest_api / ct / helpers / save-decode_test.py
diff --git a/example/diameter/launcher/resources/rest_api/ct/helpers/save-decode_test.py b/example/diameter/launcher/resources/rest_api/ct/helpers/save-decode_test.py
new file mode 100644 (file)
index 0000000..c4d7eab
--- /dev/null
@@ -0,0 +1,22 @@
+import pytest
+
+
+@pytest.mark.helpers
+def test_001_save_decoded(saveB64Artifact, b64_encode, resources, admlc):
+
+  diameterHex = resources("aaa.hex")
+  #requestBody = resources("aaa-diameterHex.json.in", diameterHex=diameterHex.rstrip())
+  requestBodyDict = { "diameterHex":"{}".format(diameterHex.rstrip()) }
+
+  # reponse field in response body, should carry the base64 encoding for xml message decoded by ADML:
+  xmlExpected = resources("aaa.xml")
+  responseBodyRef = { "success":"true", "response":"{}".format(b64_encode(xmlExpected)) }
+
+  # Send POST
+  response = admlc.postDict("/decode", requestBodyDict)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Save artifact from base64 encoded string received
+  saveB64Artifact(response["body"]["response"], "helpers/decode")