def setDoubleBet(receiptID, bet_value, bet_odd, match1_ID, match2_ID, result_1,
                 result_2):
    '''
    @param receiptID:string, receipt ID which Winner issue
    @param bet_value:float, amount of money that place on the bet
    @param bet_odd:float, the odds that the bets holds, given by Winner
    @param match1_ID:string, the ID of the first match that the bet place on
    @param match2_ID:string, the ID of the second match that the bet place on
    @param result_1:string, the outcome of the first match we expect ('1','X','2')
    @param result_2:string, the outcome of the second match we expect ('1','X','2')
    @return:None
    '''
    try:
        match1: Match = DBController.findMatch(match1_ID)
        match2: Match = DBController.findMatch(match2_ID)
        result1 = enumDICT[result_1]
        result2 = enumDICT[result_2]
        form = BetForm(receiptID=receiptID,
                       bet_value=bet_value,
                       bet_odd=bet_odd,
                       bets_list=[(match1, result1), (match2, result2)])
        match1.associateBetForm(receiptID)
        match2.associateBetForm(receiptID)
        DBController.saveBetForm(form.toDTO())
        return True
    except KeyError:
        print("Could not find the associate ENUM")
        return False
    except:
        print("An error has been occurred")
        return False
예제 #2
0
 def test_saveBetForm(self):
     db.DBConnection.BetForms.remove({})
     form = betForm(receiptID='ID',
                    date=today,
                    bet_value=10.3131,
                    bet_odd=11.33,
                    isWin=False,
                    profitExpectation=10.3131 * 11.33,
                    bets=[('{}_TeamA_TeamB'.format(today), '1')])
     db.saveBetForm(form)
     found = betForm.from_dict(
         db.convertStrtoDate(
             db.DBConnection.BetForms.find_one({"receiptID": 'ID'},
                                               projection={'_id': False})))
     self.assertEqual(form, found)
예제 #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)