def test_frac_payout(self): config = Configuration(base_bet=10, payout=1.5, loss_adder=50) account = Account(balance=100) simulation = Simulation(config=config, account=account) simulation.account.subtract(10) simulation.win_roll(simulation.account) self.assertEqual( simulation.account.get_balance(), 105, "Balance not properly increased with a payout of" " 1.5X")
def test_balance_not_changed(self): account = Account(balance=100) config = Configuration(base_bet=10, payout=2, loss_adder=0) simulation = Simulation(config=config, account=account) simulation.lose_roll() # The balance should not be changed after a roll is lost, because the # account is charged only once before the roll and is not charged again # regardless of a win or loss. self.assertEqual(simulation.account.get_balance(), 100, "Balance was changed when roll was lost.")
def test_base_bet_2(self): config = Configuration(base_bet=2, payout=2, iterations=1, loss_adder=100) account = Account(balance=10) simulation = Simulation(config=config, account=account, random_seed=12) sim_result = simulation.single_sim() self.assertEqual( sim_result.get_balances(), [10, 8, 12, 10, 6], "Incorrect sequence of balances in single simulation," " base_bet=2")
def test_base_bet_1(self): config = Configuration(base_bet=1, payout=2, iterations=1, loss_adder=100) account = Account(balance=5) simulation = Simulation(config=config, account=account, random_seed=4) sim_result = simulation.single_sim() self.assertEqual( sim_result.get_balances(), [5, 6, 5, 7, 6, 4, 8, 9, 10, 11, 10, 8, 12, 13, 14, 13, 11, 7], "Incorrect sequence of balances in " "single simulation, base_bet=1")
def test_positive(self): account = Account(balance=20) account.add(5) self.assertEqual(account.get_balance(), 25, "The balance was not appropriately added to when a " "positive integer of 5 was added")
def test_float(self): account = Account(balance=20) account.subtract(5.5) self.assertEqual(account.get_balance(), 15, "The balance was not appropriately subtracted from" " when a float of 5.5 was subtracted")
def test_zero(self): account = Account(balance=20) account.subtract(0) self.assertEqual(account.get_balance(), 20, "The balance was did not remain the same when 0 was" " subtracted")
def test_negative(self): account = Account(balance=20) account.subtract(-5) self.assertEqual(account.get_balance(), 25, "The balance was not appropriately subtracted from" " to when a negative integer of -5 was subtracted")
def test_positive(self): account = Account(balance=20) account.subtract(5) self.assertEqual(account.get_balance(), 15, "The balance was not appropriately subtracted from" " when a positive integer of 5 was subtracted")
def test_float(self): account = Account(balance=20) account.add(5.5) self.assertEqual(account.get_balance(), 25, "The balance was not appropriately added to when a " "float of 5.5 was added")
def test_negative(self): account = Account(balance=20) account.add(-5) self.assertEqual(account.get_balance(), 15, "The balance was not appropriately added to when a " "negative integer of -5 was added")
def setUp(self): self.account = Account(balance=100) self.config = Configuration(base_bet=10, payout=2, iterations=200)
def setUp(self): self.account = Account(balance=100)
def setUp(self): # Account is not relevant to the test, but still necessary for setup self.account = Account(balance=50)
def setUp(self): # Account is not relevant to rolls, but still necessary for setup self.account = Account(balance=100)