def setMatchResult(matchID, result): ''' @param matchID:string, the ID of the match @param result:string, the result of the match ('1','X','2') @return: Match object that represent the match ''' try: match = DBController.findMatch(matchID) result = enumDICT[result] match.setResult(result) DBController.updateMatch(match.toDTO()) for receiptID in match._associateBets: DBController.findBetForm(receiptID).checkWin() return match except KeyError: print("Could not find the associate ENUM") return False except: print("An error has been occurred") return False
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)