How to use the mkmsdk.resolvers.SimpleResolver 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_integration / test_resolvers.py View on Github external
def test_resolve_with_xml_data():
    """Verifies posting xml data to backend returns a positive response."""
    resolver = SimpleResolver(_API_MAP["1.1"]["api_sandbox_root"])

    simple_api_map = {"url": "/stock", "method": "post"}

    # Data posted to MKM, we post an XML because the API
    # doesn't accept anything else
    data = """
                
                    <article>
                        100569
                        1
                        Inserted through the API
                        1
                        4
                        EX
                        true
                        false</article>
github evonove / mkm-sdk / tests / tests_unit / test_resolvers.py View on Github external
def test_if_bad_api_map_is_handled_correctly():
    """Verifies setup throws an exception if api map used is empty."""

    live_resolver = SimpleResolver(_API_MAP["1.1"]["api_root"])
    empty_api_map = {}

    with pytest.raises(Exception):
        live_resolver.setup()

    with pytest.raises(Exception):
        live_resolver.setup(empty_api_map)
github evonove / mkm-sdk / tests / tests_unit / test_resolvers.py View on Github external
def test_if_setup_works_correctly():
    """Verifies setup correctly formats the url."""

    live_resolver = SimpleResolver(_API_MAP["1.1"]["api_root"])
    simple_api_map = {"url": "/account", "method": "get"}
    expected_url = "/account"
    expected_url_with_parameters = "/user/SimpleUser"
    expected_method = "get"
    simple_api_map_with_parameters = {"url": "/user/{user}", "method": "get"}

    live_resolver.setup(simple_api_map)

    assert live_resolver.url == expected_url
    assert live_resolver.method == expected_method

    live_resolver.setup(simple_api_map_with_parameters, user="SimpleUser")

    assert live_resolver.url == expected_url_with_parameters
    assert live_resolver.method == expected_method
github evonove / mkm-sdk / tests / tests_unit / test_resolvers.py View on Github external
def test_setup_escapes_additional_parameters():
    """Verifies setup escapes parameters containing spaces or special chars."""
    live_resolver = SimpleResolver(_API_MAP["1.1"]["api_root"])
    simple_api_map = {"url": "/products/{name}/{game}/{language}/{match}", "method": "get"}
    expected_url = "/products/Jace%2C%20the%20Mind%20Sculptor/1/1/False"

    live_resolver.setup(simple_api_map, name="Jace, the Mind Sculptor", game=1, language=1, match=False)

    assert live_resolver.url == expected_url