From bb74a8a84d77347c0df46ea4c58dad336a252e2b Mon Sep 17 00:00:00 2001 From: "albert.zecheru" Date: Fri, 3 Apr 2020 19:51:15 +0200 Subject: [PATCH 1/3] Added return of value for accepted string type for xsd:base64Binary. --- src/zeep/xsd/types/builtins.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zeep/xsd/types/builtins.py b/src/zeep/xsd/types/builtins.py index 5d93ef8ac..48d89889c 100644 --- a/src/zeep/xsd/types/builtins.py +++ b/src/zeep/xsd/types/builtins.py @@ -339,6 +339,8 @@ class Base64Binary(BuiltinType, AnySimpleType): @check_no_collection def xmlvalue(self, value): + if isinstance(value, six.string_types): + return value return base64.b64encode(value) def pythonvalue(self, value): From 129a4584936e8ac17ebc2f38b901b0cb9590e7aa Mon Sep 17 00:00:00 2001 From: "albert.zecheru" Date: Fri, 3 Apr 2020 20:04:16 +0200 Subject: [PATCH 2/3] Added assert for accepted string type for xsd:base64Binary. --- tests/test_xsd_builtins.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_xsd_builtins.py b/tests/test_xsd_builtins.py index 97b22e3ef..855d915da 100644 --- a/tests/test_xsd_builtins.py +++ b/tests/test_xsd_builtins.py @@ -313,6 +313,10 @@ class TestBase64Binary: def test_xmlvalue(self): instance = builtins.Base64Binary() assert instance.xmlvalue(b"hoi") == b"aG9p" + assert ( + instance.xmlvalue("aG9p") + == "aG9p" + ) def test_pythonvalue(self): instance = builtins.Base64Binary() From 71b6e3bae21db514ac3df5c376935b658f8309be Mon Sep 17 00:00:00 2001 From: "albert.zecheru" Date: Fri, 3 Apr 2020 20:06:20 +0200 Subject: [PATCH 3/3] Fixed missing assert statement in unit test. --- tests/test_xsd_builtins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_xsd_builtins.py b/tests/test_xsd_builtins.py index 855d915da..373b70713 100644 --- a/tests/test_xsd_builtins.py +++ b/tests/test_xsd_builtins.py @@ -222,8 +222,8 @@ def test_pythonvalue(self): class TestgYear: def test_xmlvalue(self): instance = builtins.gYear() - instance.xmlvalue((2001, None)) == "2001" - instance.xmlvalue((2001, pytz.utc)) == "2001Z" + assert instance.xmlvalue((2001, None)) == "2001" + assert instance.xmlvalue((2001, pytz.utc)) == "2001Z" def test_pythonvalue(self): instance = builtins.gYear()