Ejemplo n.º 1
0
def test_person_missing_last_name_error(session, person_data):
    """Person 006: Verify error if last name is missing from Persons data."""
    generic_data_without_last = {
        key: value
        for key, value in person_data['generic'].items() if key != 'last_name'
    }
    generic_person = mcp.Persons(**generic_data_without_last)
    with pytest.raises(IntegrityError):
        session.add(generic_person)
        session.commit()
Ejemplo n.º 2
0
def test_person_missing_birth_date_error(session, person_data):
    """Person 007: Verify error if birth date is missing from Persons data."""
    generic_data_without_dob = {
        key: value
        for key, value in person_data['generic'].items() if key != 'birth_date'
    }
    generic_person = mcp.Persons(**generic_data_without_dob)
    with pytest.raises(IntegrityError):
        session.add(generic_person)
        session.commit()
Ejemplo n.º 3
0
def test_person_nickname(session, person_data):
    """Person 004: Return correct name of Person with nickname."""
    persons = [
        mcp.Persons(**data) for key, records in person_data.items()
        for data in records if key in ['player'] and 'nick_name' in data
    ]
    session.add_all(persons)

    person_from_db = session.query(mcp.Persons).one()

    assert person_from_db.full_name == u"Cristiano Ronaldo"
    assert person_from_db.official_name == u"Cristiano Ronaldo Aveiro dos Santos"
Ejemplo n.º 4
0
def test_person_eastern_naming_order(session, person_data):
    """Person 003: Return correct format of Person's name with Eastern naming order."""
    persons = [
        mcp.Persons(**data) for key, records in person_data.items()
        for data in records if key in ['player', 'manager', 'referee']
    ]
    session.add_all(persons)

    person_from_db = session.query(mcp.Persons).filter(
        mcp.Persons.order == enums.NameOrderType.eastern).one()
    assert person_from_db.full_name == u"Son Heung-Min"
    assert person_from_db.full_name == person_from_db.official_name
Ejemplo n.º 5
0
def test_person_middle_naming_order(session, person_data):
    """Person 002: Return correct format of Person's name with Western Middle naming order."""
    persons = [
        mcp.Persons(**data) for key, records in person_data.items()
        for data in records if key in ['player', 'manager', 'referee']
    ]
    session.add_all(persons)

    person_from_db = session.query(mcp.Persons).filter(
        mcp.Persons.order == enums.NameOrderType.middle).one()
    assert person_from_db.full_name == u"Miguel Ángel Ponce"
    assert person_from_db.official_name == u"Miguel Ángel Ponce Briseño"
Ejemplo n.º 6
0
def test_person_generic_insert(session, person_data):
    """Person 001: Insert generic personnel data into Persons model and verify data."""
    generic_person = mcp.Persons(**person_data['generic'])
    session.add(generic_person)
    record = session.query(mcp.Persons).one()
    assert record.full_name == u"John Doe"
    assert record.official_name == u"John Doe"
    assert record.age(date(2010, 1, 1)) == 30
    assert record.exact_age(date(2010, 3, 15)) == (30, 74)
    assert repr(
        record
    ) == u"<Person(name=John Doe, country=Portlandia, DOB=1980-01-01)>"
Ejemplo n.º 7
0
def test_person_age_query(session, person_data):
    """Person 008: Verify record retrieved when Persons is queried for matching ages."""
    reference_date = date(2015, 7, 1)
    persons = [
        mcp.Persons(**data) for key, records in person_data.items()
        for data in records if key in ['player', 'manager', 'referee']
    ]
    session.add_all(persons)
    records = session.query(
        mcp.Persons).filter(mcp.Persons.age(reference_date) == 22)

    assert records.count() == 1

    son_hm = records.all()[0]
    assert son_hm.age(reference_date) == 22
    assert son_hm.exact_age(reference_date) == (22, 358)