Пример #1
0
	def test_isValidBet(self):
		self.assertTrue(utils.isValidBet('W','3','30'))
		self.assertTrue(utils.isValidBet('E','3,4','30'))
		self.assertTrue(utils.isValidBet('P','3','30'))
		self.assertFalse(utils.isValidBet('W','3,4','30'))
		self.assertFalse(utils.isValidBet('P','3','-30'))
		self.assertFalse(utils.isValidBet('D','3','30'))
		self.assertFalse(utils.isValidBet('E','3,3','30'))
		self.assertFalse(utils.isValidBet('E','3,4','30.0'))
		self.assertFalse(utils.isValidBet('EW','3,4','30'))
		self.assertFalse(utils.isValidBet('E','3,W4','30'))
Пример #2
0
    if not line.strip():
        # empty line? OK, we'll just skip it
        continue
        # any valid input should have exactly 4 parts
    elif len(break_down) != 4:
        print "Invalid input format: ", line
        break
    elif break_down[0] == "Bet":
        # we could have a class Bet but it is not needed in our case
        # Selections will be validate as non-negative integers, but we'll store them in a dic as a string
        product = break_down[1]
        # Assume if selection is started with '0', e.g. '03' , it is invalid
        selections = break_down[2]
        stake = break_down[3]

        if utils.isValidBet(product, selections, stake):
            if product == "W":
                win_pool.updatePool(int(stake), selections)
            elif product == "P":
                place_pool.updatePool(int(stake), selections)
            elif product == "E":
                exacta_pool.updatePool(int(stake), selections)
        else:
            print "Invalid input as a Bet: ", line
            break
    elif break_down[0] == "Result":
        # No need for a result class as well
        # Assume that selection is not started with '0', e.g. '03'
        first = break_down[1]
        second = break_down[2]
        third = break_down[3]