Exemplo n.º 1
0
def test_player_lookupID():
    # Setup
    log = Log('test.log')
    p = Player()
    p.connectDB()

    # Format error
    with pytest.raises(RuntimeError) as excinfo:
        needle = 'Wil'
        p.lookupID(needle, log)
    assert 'lookupID requires a dictionary' in str(excinfo.value)

    # Missing fields error
    with pytest.raises(RuntimeError) as excinfo:
        needle = {
            'FirstName': 'Wil',
            'LastName': 'Trapp'
        }
        p.lookupID(needle, log)
    assert 'Submitted data is missing the following fields' in str(excinfo.value)

    # Need a test of successful lookups
    needle = {
        'FirstName': 'Sample',
        'LastName': 'Player',
        'Position': 'Midfielder',
        'DOB': (1980, 1, 1, 0, 0, 0, 0, 0, 0,),
        'Hometown': 'Oneonta, NY'
    }
    assert p.lookupID(needle, log) == [15]