Example #1
0
def test_game_status_timezones():

    test_tstamp = dt.today() + timedelta(hours=-6)
    game_ongoing_date = dt.strftime(test_tstamp, "%m/%d/%y")
    game_ongoing_time = dt.strftime(test_tstamp, "%I:%M %p") + " CST"

    test_game = AUDLclasses.Game(game_ongoing_date, game_ongoing_time + " EST",
                                 game_ts(game_ongoing_date, game_ongoing_time),
                                 'Cincinnati Revolution', 'Madison Radicals')

    test_game.set_status()

    assert 2 == test_game.status, test_game.status

    test_tstamp = dt.today() + timedelta(hours=-6)
    game_ongoing_date = dt.strftime(test_tstamp, "%m/%d/%y")
    game_ongoing_time = dt.strftime(test_tstamp, "%I:%M %p") + " PST"

    test_game = AUDLclasses.Game(game_ongoing_date, game_ongoing_time,
                                 game_ts(game_ongoing_date, game_ongoing_time),
                                 'Cincinnati Revolution', 'Madison Radicals')

    test_game.set_status()

    assert 1 == test_game.status, test_game.status
Example #2
0
def test_game_set_status_final():

    d = '4/12/14'
    t = '7:00 PM EST'
    test_game = AUDLclasses.Game(d,t,game_ts(d,t),'Cincinnati Revolution','Madison Radicals')

    test_game.set_status()

    assert 2 == test_game.status, test_game.status

    test_tstamp = dt.today()+timedelta(days=-1) 
    game_over_date = dt.strftime(test_tstamp, "%m/%d/%y")
        
    test_game = AUDLclasses.Game(game_over_date,t,game_ts(game_over_date,t),'Cincinnati Revolution','Madison Radicals')
    
    test_game.set_status()

    assert 2 == test_game.status, test_game.status
Example #3
0
def test_game_set_status_upcoming():

    test_tstamp = dt.today()+timedelta(hours=2)
    game_ongoing_date = dt.strftime(test_tstamp, "%m/%d/%y")
    game_ongoing_time = dt.strftime(test_tstamp, "%I:%M %p")+" EST"

    test_game = AUDLclasses.Game(game_ongoing_date,game_ongoing_time+" EST",game_ts(game_ongoing_date,game_ongoing_time),'Cincinnati Revolution','Madison Radicals')
    
    test_game.set_status()

    assert 0 == test_game.status, test_game.status
Example #4
0
def test_game_set_status_final():

    d = '4/12/14'
    t = '7:00 PM EST'
    test_game = AUDLclasses.Game(d, t, game_ts(d, t), 'Cincinnati Revolution',
                                 'Madison Radicals')

    test_game.set_status()

    assert 2 == test_game.status, test_game.status

    test_tstamp = dt.today() + timedelta(days=-1)
    game_over_date = dt.strftime(test_tstamp, "%m/%d/%y")

    test_game = AUDLclasses.Game(game_over_date, t, game_ts(game_over_date, t),
                                 'Cincinnati Revolution', 'Madison Radicals')

    test_game.set_status()

    assert 2 == test_game.status, test_game.status
Example #5
0
def test_match_games():
    
    game_dict =  [{"teamId":"5182111044599808","gameId":"game-8ECA8C1D-6968-4FD0-A361-DE4EFF20203D","opponentName":"Cincinnati Revolution","tournamentName":"","gamePoint":1000,"wind":{"mph":0,"degrees":-1},"timestamp":"2014-04-12 19:26","date":"Sat, 4/12","time":"7:26","msSinceEpoch":1397330760000,"ours":25,"theirs":16,"timeoutDetailsJson":"{\"takenSecondHalf\":2,\"quotaPerHalf\":2,\"takenFirstHalf\":2,\"quotaFloaters\":0}"},{"teamId":"5182111044599808","gameId":"game-47F12B4E-52A2-4AC4-8047-FAC93845A51B","opponentName":"Indianapolis alleyCats","tournamentName":"","gamePoint":1000,"wind":{"mph":0,"degrees":-1},"timestamp":"2014-04-13 15:42","date":"Sun, 4/13","time":"3:42","msSinceEpoch":1397403720000,"ours":26,"theirs":21,"timeoutDetailsJson":"{\"takenSecondHalf\":2,\"quotaPerHalf\":2,\"takenFirstHalf\":2,\"quotaFloaters\":0}"}]

    d="4/12/14"
    t="7:00 PM EST"
    test_game = AUDLclasses.Game(d,t,game_ts(d,t),'Cincinnati Revolution','Madison Radicals')


    test_game.match_game(game_dict,False)

    assert test_game.home_score == 16, test_game.home_score
    assert test_game.away_score == 25, test_game.away_score
Example #6
0
    def add_games(self, filename="2016_Schedule.csv"):
        """
        Adds any games for the team from a given file containing the League
        or team schedule for the current season.
        """

        # open the json schedule doc
        schedule = open(filename, 'r')

        reader = csv.reader(schedule, delimiter=',')

        reader.next()  #strip first line of reader

        self.Games = {}
        team_games = []
        for game in reader:
            if self.full_name() in game[5] or self.full_name() in game[6]:
                print "Adding games for " + self.full_name() + "..."
                date = game[0]
                time = game[1].strip()
                if "" == time:
                    time = '7:00 PM CST'  #waiting for real times from the AUDL
                else:
                    time += " " + game[2].strip() + " " + game[3].strip(
                    )  #now add the rest of the time attribs
                tstamp = game_ts(date, time)
                week = game[4]
                hteam = game[5].strip()
                ateam = game[6].strip()

                #check if this team is part of a league
                if self.League != None:
                    #if yes, then see if this game already exists in the other team
                    other_team = ateam if self.full_name() in hteam else hteam
                    print "Checking if " + other_team + " already has this game."
                    print other_team, date
                    exists, existing_game = self.League.league_game_exist(
                        other_team, date)
                    print "It does." if exists else "It doesn't."

                    #if the other team has this game, add the returned game to this team
                    #otherwise create a new game class for this team
                    self.Games[date] = existing_game if exists else Game(
                        date, time, tstamp, hteam, ateam, week)
                #if this team is not part of a league, create a new game regardless
                else:
                    self.Games[date] = Game(date, time, tstamp, hteam, ateam,
                                            week)

        schedule.close()
Example #7
0
    def add_games(self, filename="2016_Schedule.csv"):
        """
        Adds any games for the team from a given file containing the League
        or team schedule for the current season.
        """

        # open the json schedule doc
        schedule = open(filename, 'r')


        reader = csv.reader( schedule, delimiter=',')

        reader.next() #strip first line of reader

        self.Games = {}
        team_games = []
        for game in reader:
            if self.full_name() in game[5] or self.full_name() in game[6]:
                print "Adding games for " + self.full_name() + "..."
                date = game[0]
                time = game[1].strip()
                if "" == time: time = '7:00 PM CST' #waiting for real times from the AUDL
                else: time += " "+game[2].strip()+ " " + game[3].strip() #now add the rest of the time attribs
                tstamp = game_ts(date,time)
                week = game[4]
                hteam = game[5].strip()
                ateam = game[6].strip()
            
                #check if this team is part of a league
                if self.League != None:
                    #if yes, then see if this game already exists in the other team
                    other_team = ateam if self.full_name() in hteam else hteam
                    print "Checking if " + other_team + " already has this game."
                    print other_team, date
                    exists, existing_game = self.League.league_game_exist(other_team, date) 
                    print "It does." if exists else "It doesn't."

                    #if the other team has this game, add the returned game to this team
                    #otherwise create a new game class for this team
                    self.Games[date] = existing_game if exists else Game(date,time,tstamp,hteam,ateam, week)
                #if this team is not part of a league, create a new game regardless
                else:
                    self.Games[date] = Game(date,time,tstamp,hteam,ateam, week)

        schedule.close()
Example #8
0
def test_match_games():

    game_dict = [{
        "teamId":
        "5182111044599808",
        "gameId":
        "game-8ECA8C1D-6968-4FD0-A361-DE4EFF20203D",
        "opponentName":
        "Cincinnati Revolution",
        "tournamentName":
        "",
        "gamePoint":
        1000,
        "wind": {
            "mph": 0,
            "degrees": -1
        },
        "timestamp":
        "2014-04-12 19:26",
        "date":
        "Sat, 4/12",
        "time":
        "7:26",
        "msSinceEpoch":
        1397330760000,
        "ours":
        25,
        "theirs":
        16,
        "timeoutDetailsJson":
        "{\"takenSecondHalf\":2,\"quotaPerHalf\":2,\"takenFirstHalf\":2,\"quotaFloaters\":0}"
    }, {
        "teamId":
        "5182111044599808",
        "gameId":
        "game-47F12B4E-52A2-4AC4-8047-FAC93845A51B",
        "opponentName":
        "Indianapolis alleyCats",
        "tournamentName":
        "",
        "gamePoint":
        1000,
        "wind": {
            "mph": 0,
            "degrees": -1
        },
        "timestamp":
        "2014-04-13 15:42",
        "date":
        "Sun, 4/13",
        "time":
        "3:42",
        "msSinceEpoch":
        1397403720000,
        "ours":
        26,
        "theirs":
        21,
        "timeoutDetailsJson":
        "{\"takenSecondHalf\":2,\"quotaPerHalf\":2,\"takenFirstHalf\":2,\"quotaFloaters\":0}"
    }]

    d = "4/12/14"
    t = "7:00 PM EST"
    test_game = AUDLclasses.Game(d, t, game_ts(d, t), 'Cincinnati Revolution',
                                 'Madison Radicals')

    test_game.match_game(game_dict, False)

    assert test_game.home_score == 16, test_game.home_score
    assert test_game.away_score == 25, test_game.away_score