summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/tests
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-08-26 17:20:30 -0400
committerDR695H <dr695h@att.com>2019-08-26 17:33:37 -0400
commit566c583bbfe0b5a4e46af7ac53765a1340d11fc0 (patch)
tree2517b7117625794533fbf006e21fb2f69316c353 /robotframework-onap/tests
parentb7ca10dbbff71b69683751b2ba5c3da6cd44f80b (diff)
improved unicode encoding for the string in py2 and py3
Issue-ID: TEST-184 Signed-off-by: DR695H <dr695h@att.com> Change-Id: I3f6bd36fd5be7b4c143696adf6bb8f9d5f69ebc7
Diffstat (limited to 'robotframework-onap/tests')
-rw-r--r--robotframework-onap/tests/ONAPLibrary/RequestsHelperTests.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/robotframework-onap/tests/ONAPLibrary/RequestsHelperTests.py b/robotframework-onap/tests/ONAPLibrary/RequestsHelperTests.py
index 29a0584..11d3cfe 100644
--- a/robotframework-onap/tests/ONAPLibrary/RequestsHelperTests.py
+++ b/robotframework-onap/tests/ONAPLibrary/RequestsHelperTests.py
@@ -44,7 +44,27 @@ class RequestsHelperTests(TestCase):
def test_post(self):
with requests_mock.mock() as m:
rh = RequestsHelper()
- m.get('http://test.com/', text='data')
- resp = rh.get_request(alias="alias", endpoint="http://test.com", data_path="/", sdc_user="test123",
- accept="application/json", content_type="application/json", files="test/123")
- self.assertEqual("data", resp.text) \ No newline at end of file
+ m.post('http://test.com/', text='data')
+ resp = rh.post_request(alias="alias", endpoint="http://test.com", data_path="/", sdc_user="test123",
+ accept="application/json", content_type="application/json", files={'file':"test/123"})
+ self.assertEqual("data", resp.text)
+
+ def test_md5_string(self):
+ with requests_mock.mock() as m:
+ rh = RequestsHelper()
+ m.post('http://test.com/', text='data', additional_matcher=self._match_md5_request_header)
+ resp = rh.post_request(alias="alias", endpoint="http://test.com", data_path="/", sdc_user="test123",
+ accept="application/json", content_type="text/string", data="test/123")
+ self.assertEqual("data", resp.text)
+
+ def test_md5_bytes(self):
+ with requests_mock.mock() as m:
+ rh = RequestsHelper()
+ m.post('http://test.com/', text='data', additional_matcher=self._match_md5_request_header)
+ resp = rh.post_request(alias="alias", endpoint="http://test.com", data_path="/", sdc_user="test123",
+ accept="application/json", content_type="text/string", data=b"test/123")
+ self.assertEqual("data", resp.text)
+
+ @staticmethod
+ def _match_md5_request_header(request):
+ return (request.headers.get('Content-MD5', None)) is not None