<commit_before># coding=utf-8
from datetime import date

import pytest
from sqlalchemy.sql import func
from sqlalchemy.exc import DataError, IntegrityError

import models.common.enums as enums
import models.common.overview as mco


def test_country_insert(session):
        """Country 001: Insert a single record into Countries table and verify data."""
        england = mco.Countries(name=u'England', confederation=enums.ConfederationType.europe)
        session.add(england)

        country = session.query(mco.Countries).all()

        assert country[0].name == u'England'
        assert country[0].confederation.value == 'UEFA'
        assert repr(country[0]) == "<Country(id={0}, name=England, confed=UEFA)>".format(country[0].id)


def test_country_unicode_insert(session):
    """Country 002: Insert a single record with Unicode characters into Countries table and verify data."""
    ivory_coast = mco.Countries(name=u"Côte d'Ivoire", confederation=enums.ConfederationType.africa)
    session.add(ivory_coast)

    country = session.query(mco.Countries).filter_by(confederation=enums.ConfederationType.africa).one()

    assert country.name == u"Côte d'Ivoire"
    assert country.confederation.value == 'CAF'


def test_country_name_overflow_error(session):
    """Country 003: Verify error if country name exceeds field length."""
    too_long_name = "blahblah" * 8
    too_long_country = mco.Countries(name=unicode(too_long_name), confederation=enums.ConfederationType.north_america)
    with pytest.raises(DataError):
        session.add(too_long_country)
        session.commit()


def test_competition_insert(session):
    """Competition 001: Insert a single record into Competitions table and verify data."""
    record = mco.Competitions(name=u"English Premier League", level=1)
    session.add(record)

    competition = session.query(mco.Competitions).filter_by(level=1).one()

    assert competition.name == u"English Premier League"
    assert competition.level == 1


def test_competition_unicode_insert(session):<commit_msg>Update suite to test functionality of revised Country model<commit_after># coding=utf-8
from datetime import date

import pytest
from sqlalchemy.sql import func
from sqlalchemy.exc import DataError, IntegrityError

import models.common.enums as enums
import models.common.overview as mco


def test_country_insert(session):
        """Country 001: Insert a single record into Countries table and verify data."""
        england = mco.Countries(name=u'England', code="ENG", confederation=enums.ConfederationType.europe)
        session.add(england)

        country = session.query(mco.Countries).all()

        assert country[0].name == u'England'
        assert country[0].code == "ENG"
        assert country[0].confederation.value == 'UEFA'
        assert repr(country[0]) == "<Country(id={0}, name=England, trigram=ENG, confed=UEFA)>".format(country[0].id)


def test_country_unicode_insert(session):
    """Country 002: Insert a single record with Unicode characters into Countries table and verify data."""
    ivory_coast = mco.Countries(name=u"Côte d'Ivoire", confederation=enums.ConfederationType.africa)
    session.add(ivory_coast)

    country = session.query(mco.Countries).filter_by(confederation=enums.ConfederationType.africa).one()

    assert country.name == u"Côte d'Ivoire"
    assert country.confederation.value == 'CAF'


def test_country_name_overflow_error(session):
    """Country 003: Verify error if country name exceeds field length."""
    too_long_name = "blahblah" * 8
    too_long_country = mco.Countries(name=unicode(too_long_name), confederation=enums.ConfederationType.north_america)
    with pytest.raises(DataError):
        session.add(too_long_country)
        session.commit()


def test_country_code_error(session):
    too_long_code = "BOGUS"
    country = mco.Countries(name=unicode("Fredonia"), code=too_long_code,
                            confederation=enums.ConfederationType.south_america)
    with pytest.raises(DataError):
        session.add(country)
        session.commit()


def test_competition_insert(session):
    """Competition 001: Insert a single record into Competitions table and verify data."""
    record = mco.Competitions(name=u"English Premier League", level=1)
    session.add(record)

    competition = session.query(mco.Competitions).filter_by(level=1).one()

    assert competition.name == u"English Premier League"
    assert competition.level == 1


def test_competition_unicode_insert(session):
{'fraction_non_alphanumeric': 0.10715076378127075, 'fraction_numerical': 0.009962364401151207, 'mean_word_length': 4.4963503649635035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '80492', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1375, 'n_words': 306}