How to use the jsonmodels.utilities.compare_schemas function in jsonmodels

To help you get started, we’ve selected a few jsonmodels 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 jazzband / jsonmodels / tests / test_utilities.py View on Github external
def test_allowed_types():
    """Only lists and dicts are allowed."""
    utilities.compare_schemas(['one'], ['one'])
    utilities.compare_schemas({'one': 'two'}, {'one': 'two'})

    with pytest.raises(RuntimeError):
        utilities.compare_schemas(('tuple',), ('tuple',))

    with pytest.raises(RuntimeError):
        utilities.compare_schemas({'this_is': 'dict'}, ['list'])

    assert utilities.compare_schemas('string', 'string')
    assert utilities.compare_schemas(42, 42)
    assert utilities.compare_schemas(23.0, 23.0)
    assert utilities.compare_schemas(True, True)

    assert not utilities.compare_schemas('string', 'other string')
    assert not utilities.compare_schemas(42, 1)
    assert not utilities.compare_schemas(23.0, 24.0)
    assert not utilities.compare_schemas(True, False)
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
def test_basic_comparison():
    assert utilities.compare_schemas({'one': 'value'}, {'one': 'value'})
    assert utilities.compare_schemas(['one', 'two'], ['one', 'two'])
    assert utilities.compare_schemas(['one', 'two'], ['two', 'one'])
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
with pytest.raises(RuntimeError):
        utilities.compare_schemas(('tuple',), ('tuple',))

    with pytest.raises(RuntimeError):
        utilities.compare_schemas({'this_is': 'dict'}, ['list'])

    assert utilities.compare_schemas('string', 'string')
    assert utilities.compare_schemas(42, 42)
    assert utilities.compare_schemas(23.0, 23.0)
    assert utilities.compare_schemas(True, True)

    assert not utilities.compare_schemas('string', 'other string')
    assert not utilities.compare_schemas(42, 1)
    assert not utilities.compare_schemas(23.0, 24.0)
    assert not utilities.compare_schemas(True, False)
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
"""Only lists and dicts are allowed."""
    utilities.compare_schemas(['one'], ['one'])
    utilities.compare_schemas({'one': 'two'}, {'one': 'two'})

    with pytest.raises(RuntimeError):
        utilities.compare_schemas(('tuple',), ('tuple',))

    with pytest.raises(RuntimeError):
        utilities.compare_schemas({'this_is': 'dict'}, ['list'])

    assert utilities.compare_schemas('string', 'string')
    assert utilities.compare_schemas(42, 42)
    assert utilities.compare_schemas(23.0, 23.0)
    assert utilities.compare_schemas(True, True)

    assert not utilities.compare_schemas('string', 'other string')
    assert not utilities.compare_schemas(42, 1)
    assert not utilities.compare_schemas(23.0, 24.0)
    assert not utilities.compare_schemas(True, False)
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
def test_basic_comparison():
    assert utilities.compare_schemas({'one': 'value'}, {'one': 'value'})
    assert utilities.compare_schemas(['one', 'two'], ['one', 'two'])
    assert utilities.compare_schemas(['one', 'two'], ['two', 'one'])
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
utilities.compare_schemas(['one'], ['one'])
    utilities.compare_schemas({'one': 'two'}, {'one': 'two'})

    with pytest.raises(RuntimeError):
        utilities.compare_schemas(('tuple',), ('tuple',))

    with pytest.raises(RuntimeError):
        utilities.compare_schemas({'this_is': 'dict'}, ['list'])

    assert utilities.compare_schemas('string', 'string')
    assert utilities.compare_schemas(42, 42)
    assert utilities.compare_schemas(23.0, 23.0)
    assert utilities.compare_schemas(True, True)

    assert not utilities.compare_schemas('string', 'other string')
    assert not utilities.compare_schemas(42, 1)
    assert not utilities.compare_schemas(23.0, 24.0)
    assert not utilities.compare_schemas(True, False)
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
utilities.compare_schemas({'one': 'two'}, {'one': 'two'})

    with pytest.raises(RuntimeError):
        utilities.compare_schemas(('tuple',), ('tuple',))

    with pytest.raises(RuntimeError):
        utilities.compare_schemas({'this_is': 'dict'}, ['list'])

    assert utilities.compare_schemas('string', 'string')
    assert utilities.compare_schemas(42, 42)
    assert utilities.compare_schemas(23.0, 23.0)
    assert utilities.compare_schemas(True, True)

    assert not utilities.compare_schemas('string', 'other string')
    assert not utilities.compare_schemas(42, 1)
    assert not utilities.compare_schemas(23.0, 24.0)
    assert not utilities.compare_schemas(True, False)
github jazzband / jsonmodels / tests / test_utilities.py View on Github external
def test_allowed_types():
    """Only lists and dicts are allowed."""
    utilities.compare_schemas(['one'], ['one'])
    utilities.compare_schemas({'one': 'two'}, {'one': 'two'})

    with pytest.raises(RuntimeError):
        utilities.compare_schemas(('tuple',), ('tuple',))

    with pytest.raises(RuntimeError):
        utilities.compare_schemas({'this_is': 'dict'}, ['list'])

    assert utilities.compare_schemas('string', 'string')
    assert utilities.compare_schemas(42, 42)
    assert utilities.compare_schemas(23.0, 23.0)
    assert utilities.compare_schemas(True, True)

    assert not utilities.compare_schemas('string', 'other string')
    assert not utilities.compare_schemas(42, 1)
    assert not utilities.compare_schemas(23.0, 24.0)
    assert not utilities.compare_schemas(True, False)
github jazzband / jsonmodels / tests / test_circular_references.py View on Github external
def test_generate_circular_schema():
    schema = Primary.to_json_schema()

    pattern = get_fixture('schema_circular.json')
    assert compare_schemas(pattern, schema) is True
github jazzband / jsonmodels / tests / test_circular_references.py View on Github external
def test_generate_circular_schema2():
    schema = Filesystem.to_json_schema()

    pattern = get_fixture('schema_circular2.json')
    assert compare_schemas(pattern, schema) is True