Hello community, here is the log from the commit of package python-msrest for openSUSE:Factory checked in at 2020-10-02 17:23:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-msrest (Old) and /work/SRC/openSUSE:Factory/.python-msrest.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-msrest" Fri Oct 2 17:23:05 2020 rev:11 rq:830913 version:0.6.18 Changes: -------- --- /work/SRC/openSUSE:Factory/python-msrest/python-msrest.changes 2020-06-17 14:53:33.177641796 +0200 +++ /work/SRC/openSUSE:Factory/.python-msrest.new.4249/python-msrest.changes 2020-10-02 17:23:22.698238993 +0200 @@ -1,0 +2,8 @@ +Fri Aug 28 13:04:38 UTC 2020 - John Paul Adrian Glaubitz <adrian.glaub...@suse.com> + +- New upstream release + + Version 0.6.18 + + For detailed information about changes see the + README.rst file provided with this package + +------------------------------------------------------------------- Old: ---- msrest-0.6.16.tar.gz New: ---- msrest-0.6.18.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-msrest.spec ++++++ --- /var/tmp/diff_new_pack.sWp2Df/_old 2020-10-02 17:23:23.806239656 +0200 +++ /var/tmp/diff_new_pack.sWp2Df/_new 2020-10-02 17:23:23.810239659 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-msrest -Version: 0.6.16 +Version: 0.6.18 Release: 0 Summary: AutoRest swagger generator Python client runtime License: MIT ++++++ msrest-0.6.16.tar.gz -> msrest-0.6.18.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/PKG-INFO new/msrest-0.6.18/PKG-INFO --- old/msrest-0.6.16/PKG-INFO 2020-06-09 18:52:20.000000000 +0200 +++ new/msrest-0.6.18/PKG-INFO 2020-07-28 17:03:54.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: msrest -Version: 0.6.16 +Version: 0.6.18 Summary: AutoRest swagger generator Python client runtime. Home-page: https://github.com/Azure/msrest-for-python Author: Microsoft Corporation @@ -27,6 +27,22 @@ Release History --------------- + 2020-07-27 Version 0.6.18 + +++++++++++++++++++++++++ + + **Features** + + - Add support for attributes/text in the same XML node #218 + + + 2020-06-25 Version 0.6.17 + +++++++++++++++++++++++++ + + **Bugfixes** + + - Fix XML and discriminator #214 + + 2020-06-09 Version 0.6.16 +++++++++++++++++++++++++ @@ -720,10 +736,10 @@ Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: Software Development Provides-Extra: async diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/README.rst new/msrest-0.6.18/README.rst --- old/msrest-0.6.16/README.rst 2020-06-09 18:51:38.000000000 +0200 +++ new/msrest-0.6.18/README.rst 2020-07-28 17:03:05.000000000 +0200 @@ -20,6 +20,22 @@ Release History --------------- +2020-07-27 Version 0.6.18 ++++++++++++++++++++++++++ + +**Features** + +- Add support for attributes/text in the same XML node #218 + + +2020-06-25 Version 0.6.17 ++++++++++++++++++++++++++ + +**Bugfixes** + +- Fix XML and discriminator #214 + + 2020-06-09 Version 0.6.16 +++++++++++++++++++++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/msrest/serialization.py new/msrest-0.6.18/msrest/serialization.py --- old/msrest-0.6.16/msrest/serialization.py 2020-06-09 18:51:38.000000000 +0200 +++ new/msrest-0.6.18/msrest/serialization.py 2020-07-28 17:03:05.000000000 +0200 @@ -366,8 +366,15 @@ for subtype_key in cls.__dict__.get('_subtype_map', {}).keys(): subtype_value = None - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor( + subtype_key, + cls._attribute_map[subtype_key], + response + ) if subtype_value: # Try to match base class. Can be class name only # (bug to fix in Autorest to support x-ms-discriminator-name) @@ -527,6 +534,9 @@ xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue if isinstance(new_attr, list): serialized.extend(new_attr) elif isinstance(new_attr, ET.Element): @@ -1240,6 +1250,10 @@ if xml_desc.get("attr", False): return data.get(xml_name) + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + # Scenario where I take the local name: # - Wrapped node # - Internal type is an enum (considered basic types) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/msrest/version.py new/msrest-0.6.18/msrest/version.py --- old/msrest-0.6.16/msrest/version.py 2020-06-09 18:51:38.000000000 +0200 +++ new/msrest-0.6.18/msrest/version.py 2020-07-28 17:03:05.000000000 +0200 @@ -25,4 +25,4 @@ # -------------------------------------------------------------------------- #: version of this package. Use msrest.__version__ instead -msrest_version = "0.6.16" +msrest_version = "0.6.18" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/msrest.egg-info/PKG-INFO new/msrest-0.6.18/msrest.egg-info/PKG-INFO --- old/msrest-0.6.16/msrest.egg-info/PKG-INFO 2020-06-09 18:52:20.000000000 +0200 +++ new/msrest-0.6.18/msrest.egg-info/PKG-INFO 2020-07-28 17:03:54.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: msrest -Version: 0.6.16 +Version: 0.6.18 Summary: AutoRest swagger generator Python client runtime. Home-page: https://github.com/Azure/msrest-for-python Author: Microsoft Corporation @@ -27,6 +27,22 @@ Release History --------------- + 2020-07-27 Version 0.6.18 + +++++++++++++++++++++++++ + + **Features** + + - Add support for attributes/text in the same XML node #218 + + + 2020-06-25 Version 0.6.17 + +++++++++++++++++++++++++ + + **Bugfixes** + + - Fix XML and discriminator #214 + + 2020-06-09 Version 0.6.16 +++++++++++++++++++++++++ @@ -720,10 +736,10 @@ Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: Software Development Provides-Extra: async diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/setup.py new/msrest-0.6.18/setup.py --- old/msrest-0.6.16/setup.py 2020-06-09 18:51:38.000000000 +0200 +++ new/msrest-0.6.18/setup.py 2020-07-28 17:03:05.000000000 +0200 @@ -28,7 +28,7 @@ setup( name='msrest', - version='0.6.16', + version='0.6.18', author='Microsoft Corporation', packages=find_packages(exclude=["tests", "tests.*"]), url=("https://github.com/Azure/msrest-for-python"), @@ -41,10 +41,10 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', 'Topic :: Software Development'], install_requires=[ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/msrest-0.6.16/tests/test_xml_serialization.py new/msrest-0.6.18/tests/test_xml_serialization.py --- old/msrest-0.6.16/tests/test_xml_serialization.py 2020-06-09 18:51:38.000000000 +0200 +++ new/msrest-0.6.18/tests/test_xml_serialization.py 2020-07-28 17:03:05.000000000 +0200 @@ -102,6 +102,26 @@ assert result.language == u"français" + def test_basic_text(self): + """Test a XML with unicode.""" + basic_xml = u"""<?xml version="1.0" encoding="utf-8"?> + <Data language="english">I am text</Data>""" + + class XmlModel(Model): + _attribute_map = { + 'language': {'key': 'language', 'type': 'str', 'xml':{'name': 'language', 'attr': True}}, + 'content': {'key': 'content', 'type': 'str', 'xml':{'text': True}}, + } + _xml_map = { + 'name': 'Data' + } + + s = Deserializer({"XmlModel": XmlModel}) + result = s(XmlModel, basic_xml, "application/xml") + + assert result.language == "english" + assert result.content == "I am text" + def test_add_prop(self): """Test addProp as a dict. """ @@ -537,6 +557,72 @@ assert result.authorization_rules[0].type == "SharedAccessAuthorizationRule" assert result.message_count_details.active_message_count == 12 + def test_polymorphic_deserialization(self): + + basic_xml = """<?xml version="1.0"?> + <entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <Filter xsi:type="CorrelationFilter"> + <CorrelationId>12</CorrelationId> + </Filter> + </entry>""" + + class XmlRoot(Model): + _attribute_map = { + 'filter': {'key': 'Filter', 'type': 'RuleFilter'}, + } + _xml_map = { + 'name': 'entry' + } + + class RuleFilter(Model): + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + _subtype_map = { + 'type': {'CorrelationFilter': 'CorrelationFilter', 'SqlFilter': 'SqlFilter'} + } + _xml_map = { + 'name': 'Filter' + } + + class CorrelationFilter(RuleFilter): + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'correlation_id': {'key': 'CorrelationId', 'type': 'int'}, + } + + def __init__( + self, + correlation_id = None, + **kwargs + ): + super(CorrelationFilter, self).__init__(**kwargs) + self.type = 'CorrelationFilter' + self.correlation_id = correlation_id + + class SqlFilter(RuleFilter): + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + def __init__( + self, + **kwargs + ): + pytest.fail("Don't instantiate me") + + s = Deserializer({ + "XmlRoot": XmlRoot, + "RuleFilter": RuleFilter, + "SqlFilter": SqlFilter, + "CorrelationFilter": CorrelationFilter, + }) + result = s(XmlRoot, basic_xml, "application/xml") + + assert isinstance(result.filter, CorrelationFilter) + assert result.filter.correlation_id == 12 + class TestXmlSerialization: @@ -687,6 +773,31 @@ assert_xml_equals(rawxml, basic_xml) + def test_basic_text(self): + """Test a XML with unicode.""" + basic_xml = ET.fromstring("""<?xml version="1.0" encoding="utf-8"?> + <Data language="english">I am text</Data>""") + + class XmlModel(Model): + _attribute_map = { + 'language': {'key': 'language', 'type': 'str', 'xml':{'name': 'language', 'attr': True}}, + 'content': {'key': 'content', 'type': 'str', 'xml':{'text': True}}, + } + _xml_map = { + 'name': 'Data' + } + + mymodel = XmlModel( + language="english", + content="I am text" + ) + + s = Serializer({"XmlModel": XmlModel}) + rawxml = s.body(mymodel, 'XmlModel') + + assert_xml_equals(rawxml, basic_xml) + + def test_direct_array(self): """Test an ultra basic XML.""" basic_xml = ET.fromstring("""<?xml version="1.0"?>