Beispiel #1
0
def test_importer_parsePlayer(excel, lineup):
    # Need to test parsePlayer's ability to deal with strings of player(s)
    game = 1
    team = 1
    duration = 90
    log = Log('test.log')
    importer = ImporterLineups(excel, log)
    player = 'Sample Player'
    result = importer.parsePlayer(player, game, team, duration)
    assert len(result) == 1
    assert result == [{'PlayerID': 15, 'PlayerName': 'Sample Player', 'TimeOn': 0, 'TimeOff': 90, 'Ejected': False, 'GameID': 1, 'TeamID': 1}]
    player = "Sample Player (Substitution 50')"
    result = importer.parsePlayer(player, game, team, duration)
    assert len(result) == 2
    player = 'Sample Player (First Substitution 50 (Second Substitution 76))'
    result = importer.parsePlayer(player, game, team, duration)
    assert len(result) == 3
    player = 'Sample Player (First Substitution 50 (Second Substitution 76 (Third Substitution 92+)))'
    result = importer.parsePlayer(player, game, team, duration)
    assert len(result) == 4
    player = 'Sample Player (First Substitution 50 (Second Substitution 76 (Third Substitution 84 (sent off 88))))'
    result = importer.parsePlayer(player, game, team, duration)
    assert len(result) == 4
    assert result[3]['PlayerName'] == 'Third Substitution'
    assert result[3]['Ejected'] is True
    assert result[3]['TimeOn'] == 84
    assert result[3]['TimeOff'] == 88