def addMatch(league, date, home_team, away_team, result=None):
    '''
    @param league:string , the league that the match took place.
    @param date:datetime object, the date that the match took place.
    @param home_team:string, name of the home team.
    @param away_team:string, name of the way team.
    @param result (OPTIONAL):string, the result of the match ('1','X','2')
    @return: Match object that represent the match
    '''
    try:
        matchID = generateMatchID()
        if result != None:
            _result = enumDICT[result]
        newMatch = Match(matchID=matchID,
                         league=league,
                         date=date,
                         home_team=home_team,
                         away_team=away_team,
                         result=_result)
        DBController.saveMatch(newMatch.toDTO())
        return newMatch
    except KeyError:
        print("Could not find the associate ENUM")
        return False
    except:
        print("An error has been occurred")
        return False
Exemplo n.º 2
0
 def test_saveMatch(self):
     db.DBConnection.Matches.remove({})
     newMatch = Match(matchID='{}_TeamA_TeamB'.format(today),
                      date=today,
                      league='league',
                      home_team='TeamA',
                      away_team='TeamB',
                      result=Result.Home)
     db.saveMatch(newMatch.toDTO())
     found = db.findMatch(matchID='{}_TeamA_TeamB'.format(today))
     self.assertEqual(newMatch, found)
Exemplo n.º 3
0
 def test_findBetForm(self):
     from Server.BetsFinancial.BetForm import BetForm
     db.DBConnection.BetForms.remove({})
     db.DBConnection.Matches.remove({})
     match = Match(matchID='{}_TeamA_TeamB'.format(today),
                   date=today,
                   league='league',
                   home_team='TeamA',
                   away_team='TeamB',
                   result=Result.Home)
     form = BetForm(receiptID='ID',
                    date=today,
                    bet_value=10.3131,
                    bet_odd=11.33,
                    bets_list=[(match, Result.Home)])
     db.saveMatch(match.toDTO())
     db.saveBetForm(form.toDTO())
     found = db.findBetForm(receiptID='ID')
     self.assertEqual(form, found)