<commit_before>from __future__ import absolute_import

# import pytest

import schematec.schema
# import schematec.converters as converters
# import schematec.validators as validators
# import schematec.exc as exc


def test_empty_schema_with_empty_value():
    schema = schematec.schema.Schema()
    assert schema({}) == {}<commit_msg>add base tests for schema<commit_after>from __future__ import absolute_import

import pytest

import schematec.schema
import schematec.converters as converters
import schematec.validators as validators
import schematec.exc as exc


def test_empty_schema_with_empty_value():
    schema = schematec.schema.Schema()
    assert schema({}) == {}


def test_empty_schema_with_non_empty_value():
    schema = schematec.schema.Schema()
    assert schema({'a': 1}) == {}


def test_numeric_to_string_converter():
    schema = schematec.schema.Schema(
        a=[converters.string]
    )
    assert schema({'a': 1}) == {'a': '1'}


def test_numeric_to_numeric_converter():
    schema = schematec.schema.Schema(
        a=[converters.numeric]
    )
    assert schema({'a': 1}) == {'a': 1}


def test_unbound_validator_required():
    schema = schematec.schema.Schema(
        a=[validators.required, converters.numeric]
    )
    assert schema({'a': '1'}) == {'a': 1}


def test_unbound_validator_required_for_missed_value():
    schema = schematec.schema.Schema(
        a=[validators.required, converters.numeric]
    )
    with pytest.raises(exc.ValidationError):
        schema({})


def test_unbound_validator_required_without_converter():
    schema = schematec.schema.Schema(
        a=[validators.required]
    )
    assert schema({'a': 1}) == {'a': 1}


def test_unbound_validator_required_for_missed_without_converter():
    schema = schematec.schema.Schema(
        a=[validators.required]
    )
    with pytest.raises(exc.ValidationError):
        schema({})
{'fraction_non_alphanumeric': 0.11767810026385224, 'fraction_numerical': 0.00474934036939314, 'mean_word_length': 4.138211382113822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7619464', 'n_tokens_mistral': 617, 'n_tokens_neox': 608, 'n_words': 121}