How to use the mkmsdk.serializer.XMLSerializer function in mkmsdk

To help you get started, we’ve selected a few mkmsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evonove / mkm-sdk / tests / tests_unit / test_serializer.py View on Github external
def test_exception_raised_if_bad_data():
    """Verifies SerializationException is raised when trying to serialize bad data"""

    data = "We can't serialize this"

    serializer = XMLSerializer()

    with pytest.raises(SerializationException):
        serializer.serialize(data=data)
github evonove / mkm-sdk / tests / tests_unit / test_serializer.py View on Github external
def test_xml_serializer():
    """Verifies that data is correctly serialized to XML"""
    data = {"action": "add", "article": [{"idArticle": 666, "amount": 2}, {"idArticle": 101, "amount": 5}]}

    serializer = XMLSerializer()
    serialized_data = serializer.serialize(data=data)

    assert '\n' in serialized_data
    assert "2" in serialized_data
    assert "666" in serialized_data
    assert "5" in serialized_data
    assert "101" in serialized_data
    assert "add" in serialized_data
    assert "" in serialized_data
github evonove / mkm-sdk / mkmsdk / resolvers.py View on Github external
def resolve(self, api_map=None, data=None, params=None, auth=None, **kwargs):
        """
        Params:
            `api_map`: Dict with urls and methods for the request
            `data`: Data sent to MKM in PUT, POST and DELETE requests
            `kwargs`: Optional additional parameters to be attached to the url

        Return:
            `response`: Returns the response received from the server
        """
        self.setup(api_map=api_map, **kwargs)

        if isinstance(data, dict):
            serializer = XMLSerializer()
            data = serializer.serialize(data=data)

        return self.api.request(url=self.url, method=self.method, data=data, params=params, auth_params=auth)