diff options
author | DR695H <dr695h@att.com> | 2019-07-19 16:55:55 -0400 |
---|---|---|
committer | DR695H <dr695h@att.com> | 2019-07-19 17:50:32 -0400 |
commit | 4c8dc6a28644cbd44084296907d54c66b447432e (patch) | |
tree | 7d98c75cee99ad3891bebc79847db0d0a1d95ae9 /robotframework-onap | |
parent | 601ead6cc5e04f276d57d118e1d94d1366278a24 (diff) |
fixing is not none
Issue-ID: TEST-174
Change-Id: I1b48d6f6839cdbb4df5eb6461ac1a053fcdfbc57
Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap')
5 files changed, 24 insertions, 6 deletions
diff --git a/robotframework-onap/ONAPLibrary/Base64Keywords.py b/robotframework-onap/ONAPLibrary/Base64Keywords.py index a87a4b9..11cc69c 100644 --- a/robotframework-onap/ONAPLibrary/Base64Keywords.py +++ b/robotframework-onap/ONAPLibrary/Base64Keywords.py @@ -11,9 +11,9 @@ class Base64Keywords(object): @keyword def base64_encode(self, string_to_encode): """generate a base64 encoded string""" - return base64.b64encode(self, string_to_encode) + return base64.b64encode(string_to_encode.encode("utf-8")) @keyword def base64_decode(self, string_to_decode): """decode a base64 encoded string""" - return base64.b64decode(self, string_to_decode) + return base64.b64decode(string_to_decode.encode("utf-8")) diff --git a/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py b/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py index de53dd1..19890ae 100644 --- a/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py +++ b/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py @@ -43,7 +43,7 @@ class BaseSDCKeywords(object): @keyword def run_post_files_request(self, endpoint, data_path, files, user, accept="application/json", auth=None): """Runs an SDC post files request""" - return self.reqs.post_request("sdc", endpoint, data_path, files, user, files=None, accept=accept, + return self.reqs.post_request("sdc", endpoint, data_path, None, user, files=files, accept=accept, content_type="multipart/form-data", auth=auth) @keyword diff --git a/robotframework-onap/ONAPLibrary/RequestsHelper.py b/robotframework-onap/ONAPLibrary/RequestsHelper.py index 9de2260..0fd0115 100644 --- a/robotframework-onap/ONAPLibrary/RequestsHelper.py +++ b/robotframework-onap/ONAPLibrary/RequestsHelper.py @@ -37,9 +37,9 @@ class RequestsHelper(object): "X-TransactionId": self.application_id + "-" + uuid, "X-FromAppId": self.application_id } - if not sdc_user_id: + if sdc_user_id is not None: headers["USER_ID"] = sdc_user_id - if not md5: + if md5 is not None: headers["Content-MD5"] = md5 return headers @@ -56,7 +56,7 @@ class RequestsHelper(object): content_type="application/json", auth=None): """Runs a post request""" logger.info("Creating session" + endpoint) - if not data: + if data is not None: md5 = hashlib.md5() md5.update(data) md5checksum = Base64Keywords().base64_encode(md5.hexdigest()) diff --git a/robotframework-onap/tests/ONAPLibrary/Base64KeywordsTests.py b/robotframework-onap/tests/ONAPLibrary/Base64KeywordsTests.py new file mode 100644 index 0000000..4c63591 --- /dev/null +++ b/robotframework-onap/tests/ONAPLibrary/Base64KeywordsTests.py @@ -0,0 +1,16 @@ +import base64 +from unittest import TestCase + +from ONAPLibrary.Base64Keywords import Base64Keywords + + +class Base64KeywordsTests(TestCase): + + def test_base64_encode(self): + enc = Base64Keywords().base64_encode("string_to_encode") + enc_base = base64.b64encode("string_to_encode".encode("utf-8")) + self.assertEqual(enc_base, enc) + + def test_base64_decode(self): + enc = Base64Keywords().base64_decode('c3RyaW5nX3RvX2RlY29kZQ==') + self.assertEqual("string_to_decode", enc.decode("utf-8")) diff --git a/robotframework-onap/tests/runner.py b/robotframework-onap/tests/runner.py index d1b217a..f9a57f5 100644 --- a/robotframework-onap/tests/runner.py +++ b/robotframework-onap/tests/runner.py @@ -7,6 +7,7 @@ from tests.vcpeutils.SoUtils_test import SoUtilsTest from tests.ONAPLibrary.ProtobufKeywordsTest import ProtobufKeywordsTest from tests.ONAPLibrary.UUIDKeywordsTest import UUIDKeywordsTest from tests.ONAPLibrary.ServiceMappingKeywordsTests import ServiceMappingKeywordsTests +from tests.ONAPLibrary.Base64KeywordsTests import Base64KeywordsTests # initialize the test suite loader = TestLoader() @@ -17,6 +18,7 @@ suite.addTests(loader.loadTestsFromTestCase(ProtobufKeywordsTest)) suite.addTests(loader.loadTestsFromTestCase(SoUtilsTest)) suite.addTests(loader.loadTestsFromTestCase(UUIDKeywordsTest)) suite.addTests(loader.loadTestsFromTestCase(ServiceMappingKeywordsTests)) +suite.addTests(loader.loadTestsFromTestCase(Base64KeywordsTests)) # initialize a runner, pass it your suite and run it runner = TextTestRunner(verbosity=3) |