"""
Tests for `appsemble.schemas`.

"""
import jsonschema
import pytest

from appsemble import schemas


def test_get():
    """
    Test if it is possible to get a schema.

    """
    app_schema = schemas.get('app')
    assert isinstance(app_schema, dict)


def test_valid(schema, data):
    """
    Test if the given data matches the given schema.

    """
    validator = jsonschema.Draft4Validator(schema)
    validator.validate(data)


def test_invalid(schema, data):
    """
    Test if the given data doesn't match the given schema.

    """
    validator = jsonschema.Draft4Validator(schema)
    with pytest.raises(jsonschema.exceptions.ValidationError):
        validator.validate(data)
