Пример #1
0
def test_league_game_exist():
    """
    Uses league data to ensure this function is working properly
    """

    test_league = AUDLclasses.League()
    test_league.add_teams(players=False, stats=False)

    # First hand it a fake team and a fake date
    assert (False,
            None) == test_league.league_game_exist('Dubai Ranchers', '4/5/03')

    # Now a real team and a fake date
    assert (False,
            None) == test_league.league_game_exist('Minnesota Wind Chill',
                                                   '4/5/03')

    # Finally a real team and a real date

    games = test_league.Teams[5638404075159552].Games

    key = unicode('4/12/14')

    game_inst = games[key]

    assert (True, game_inst) == test_league.league_game_exist(
        'Minnesota Wind Chill', '4/12/14')
Пример #2
0
def test_league_videos():

    test_league = AUDLclasses.League()

    assert 0 != len(test_league.get_videos())

    assert True == hasattr(test_league, 'Videos')
Пример #3
0
def test_single_game_merge():
    """
    Creates two team instances that share a game in the same file.
    Upon loading games from this file for both teams,
    there should be only one game in the Python instance 
    if game merging is working properly.
    """

    test_league = AUDLclasses.League()
    test_league.add_teams('multiple_teams_info',
                          games=False,
                          players=False,
                          stats=False)

    for team in test_league.Teams:
        test_league.Teams[team].add_games('test_game_data.json')

    game_instances = []

    for team in test_league.Teams:
        games = test_league.Teams[team].Games
        for game in games:
            if games[game] not in game_instances:
                game_instances.append(games[game])

    assert 1 == len(game_instances)
    for team in test_league.Teams:
        games = test_league.Teams[team].Games
        assert 1 == len(games), "%i" % len(games)
Пример #4
0
def team_roster_setup():
    test_league = AUDLclasses.League()

    test_league.add_teams("single_team_info",
                          games=False,
                          players=False,
                          stats=False)

    return test_league
Пример #5
0
def test_league_get_news():

    test_league = AUDLclasses.League()

    test_league.get_news()

    assert type(test_league.News) is dict, \
    "League's News attribute is not a dictionary, it is %s" % type(test_league.News)

    assert len(test_league.News) is not 0, \
    "League news was not popultaed. Length is zero"
Пример #6
0
def ret_games_setup():

    test_league = AUDLclasses.League()

    test_league.add_teams('single_team_info',
                          games=False,
                          players=False,
                          stats=False)

    test_league.Teams[224002].add_games('test_game_data.json')

    return test_league
Пример #7
0
def test_league_methods():

    test_league = AUDLclasses.League()

    test_league.add_teams(filename='multiple_teams_info',
                          games=False,
                          players=False,
                          stats=False)

    for team in test_league.Teams:

        assert type(team) is int
        assert isinstance(test_league.Teams[team], AUDLclasses.Team)
        assert type(test_league.Teams) is dict
Пример #8
0
def load_team_test():
    """
    Tests that the method add_teams can find a single team in the test file 
    and create an instance for it.
    """
    test_league = AUDLclasses.League()
    test_league.add_teams('single_team_info',
                          games=False,
                          players=False,
                          stats=False)
    assert 1 == len(test_league.Teams)

    assert test_league.Teams[224002].Name == 'Radicals'
    assert test_league.Teams[224002].City == 'Madison'
Пример #9
0
def test_League_attrs():

    test_league = AUDLclasses.League()

    assert type(test_league.This_week) is list

    assert type(test_league.Apple_users) is list

    assert type(test_league.Android_users) is list

    assert type(test_league.Video_feeds) is list

    assert type(test_league.RSS_feeds) is list

    assert type(test_league.Top_fives) is dict
Пример #10
0
def load_all_team_data_test():
    """
    Tests that the method add_teams can find a single team in the test file, create an
    instance of the team class, and populate its players and their statistics.
    """
    test_league = AUDLclasses.League()
    test_league.add_teams('single_team_info',
                          games=False,
                          players=False,
                          stats=False)
    for team in test_league.Teams:
        test_league.Teams[team].add_games('test_game_data.json')
        test_league.Teams[team].add_players(filename='test_players.json')

    assert 1 == len(test_league.Teams)
Пример #11
0
def test_game_exist():
    """
    Uses league data to make sure that game exists is working properly
    """

    test_league = AUDLclasses.League()
    test_league.add_teams(players=False, stats=False)

    team = test_league.Teams[5182111044599808]
    # Hand the function a false date...
    assert (False, None) == team.game_exist('4/15/11')

    key = unicode('4/13/14')
    game_inst = team.Games[key]
    # Hand the function a correct date
    assert (True, game_inst) == team.game_exist('4/13/14')
Пример #12
0
def load_teams_test():
    """
    Tests that the method add_teams can find multiple teams in the test file 
    and create an instance for it.
    """
    test_league = AUDLclasses.League()
    test_league.add_teams('multiple_teams_info',
                          games=False,
                          players=False,
                          stats=False)
    assert 2 == len(test_league.Teams)
    assert 1 == len(test_league.Divisions)

    assert test_league.Teams[224002].Name == "Radicals"
    assert test_league.Teams[224002].City == "Madison"

    assert test_league.Teams[210001].Name == "Wind Chill"
    assert test_league.Teams[210001].City == "Minnesota"
Пример #13
0
#!/usr/bin/python

import AUDLclasses
import sheet_reader as sr
import argparse
import threading
import traceback
import pickle

# Initialize the league class
AUDL = AUDLclasses.League()
# Add teams from local files and populate
# their information from the ultimate-numbers
# server
sr.get_csv(sr.spreadsheet_key, sr.Team_Info_gid, sr.Team_Info_Filename)
sr.get_csv(sr.spreadsheet_key, sr.Schedule_gid, sr.Schedule_Filename)
sr.get_csv(sr.spreadsheet_key, sr.Rosters_gid, sr.Rosters_filename)
AUDL.add_teams()
# Get news articles for the team
AUDL.get_news()

#save AUDL class to file
pickle.dump(AUDL, open('audl_db16.p', 'wb'))


def parse_args():

    parser = argparse.ArgumentParser()

    parser.add_argument('--refresh-int',
                        dest='interval',
Пример #14
0
def test_news():

    test_league = AUDLclasses.League()
    test_league.get_news()

    assert 0 != len(test_league.News)
Пример #15
0
def load_test():

    test_league = AUDLclasses.League()
    test_league.add_teams()