def test_unclean_trade(self): e = models.Effect(trade=models.Cost(), left_trade=0, right_trade=0) with self.assertRaises(models.ValidationError): e.clean() e = models.Effect(trade=None, left_trade=3, right_trade=0) with self.assertRaises(models.ValidationError): e.clean()
def test_clean_trade(self): e = models.Effect(trade=models.Cost(), left_trade=1) self.should_be_clean(e) e = models.Effect(trade=models.Cost(), right_trade=1) self.should_be_clean(e) e = models.Effect(trade=models.Cost(), left_trade=1, right_trade=1) self.should_be_clean(e)
def test_unclean_pay(self): e = models.Effect(kind_payed=models.BuildingKind(), money_per_local_building=0, money_per_neighbor_building=0) with self.assertRaises(models.ValidationError): e.clean() e = models.Effect(kind_payed=None, money_per_local_building=0, money_per_neighbor_building=2) with self.assertRaises(models.ValidationError): e.clean()
def test_clean_pay(self): e = models.Effect(kind_payed=models.BuildingKind(), money_per_local_building=1) self.should_be_clean(e) e = models.Effect(kind_payed=models.BuildingKind(), money_per_neighbor_building=1) self.should_be_clean(e) e = models.Effect(kind_payed=models.BuildingKind(), money_per_local_building=1, money_per_neighbor_building=1) self.should_be_clean(e)
def test_money_per_neighbor_special(self): e = models.Effect(money_per_neighbor_special=2) p1 = mock_player(1, 1, {'civ': 1, 'mil': 4}) p2 = mock_player(3, 1, {'civ': 2, 'mil': 4}) p3 = mock_player(5, 1, {'civ': 3, 'mil': 4}) money = e.money(p1, p2, p3) self.assertEqual(money, 16) # 2 * (3+5)
def test_money_per_neighbor_building(self): e = models.Effect(kind_payed=self.bk_civ, money_per_neighbor_building=2) p1 = mock_player(1, 1, {'civ': 1, 'mil': 4}) p2 = mock_player(1, 1, {'civ': 2, 'mil': 4}) p3 = mock_player(1, 1, {'civ': 3, 'mil': 4}) money = e.money(p1, p2, p3) self.assertEqual(money, 10) # 2 * (2+3)
def test_money_effects_accumulate(self): e = models.Effect(production=models.Cost(money=3), kind_payed=self.bk_civ, money_per_neighbor_building=2, money_per_local_building=3, money_per_neighbor_special=2, money_per_local_special=1) p1 = mock_player(1, 1, {'civ': 1, 'mil': 4}) p2 = mock_player(3, 1, {'civ': 2, 'sci': 4}) p3 = mock_player(5, 1, {'civ': 3}) money = e.money(p1, p2, p3) self.assertEqual(money, 33) # 3 + 2 * (2+3) + 3*1 + 2*(3+5) + 1*1
def test_money_per_local_special(self): e = models.Effect(money_per_local_special=2) p1 = mock_player(1, 1, {'civ': 1, 'mil': 4}) p2 = mock_player(3, 1, {'civ': 2, 'mil': 4}) money = e.money(p1, p2, p2) self.assertEqual(money, 2) # 2 * 1
def test_money_per_local_building(self): e = models.Effect(kind_payed=self.bk_civ, money_per_local_building=3) p1 = mock_player(1, 1, {'civ': 2, 'mil': 4}) p2 = mock_player(1, 1, {'civ': 5, 'mil': 4}) money = e.money(p1, p2, p2) self.assertEqual(money, 6) # 3 * 2
def test_money_from_production(self): e = models.Effect(production=models.Cost(money=3)) p = mock_player(1, 1, {'civ': 1}) money = e.money(p, p, p) self.assertEqual(money, 3)
def test_clean_simple(self): e = models.Effect() self.should_be_clean(e)