Exemplo n.º 1
0
 def setUp(self):
     self.bk_mil = models.BuildingKind(name='mil')
     self.bk_mil.save()
     self.bk_civ = models.BuildingKind(name='civ')
     self.bk_civ.save()
     self.bk_sci = models.BuildingKind(name='sci')
     self.bk_sci.save()
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 def test_score_null(self):
     k = models.BuildingKind(name='mil')
     b = models.Building(kind=k)
     with mock.patch.object(models.Building, 'effect') as mock_effect:
         mock_effect.get_score.return_value = 0
         score = b.score(
             None, None, None
         )  # using None as players, because the mock effect does not care
     self.assertEqual(score, models.Score.new())
Exemplo n.º 4
0
 def test_score_other_fail(self):
     k = models.BuildingKind(name='mil')
     b = models.Building(kind=k)
     with mock.patch.object(models.Building, 'effect') as mock_effect:
         mock_effect.get_score.return_value = 42
         with self.assertRaises(AssertionError):
             score = b.score(
                 None, None, None
             )  # using None as players, because the mock effect does not care
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 def test_score_personality(self):
     k = models.BuildingKind(name='per')
     b = models.Building(kind=k)
     with mock.patch.object(models.Building, 'effect') as mock_effect:
         mock_effect.get_score.return_value = 42
         score = b.score(
             None, None, None
         )  # using None as players, because the mock effect does not care
     self.assertEqual(
         score,
         models.Score(treasury=0,
                      military=0,
                      special=0,
                      civilian=0,
                      economy=0,
                      science=0,
                      personality=42))
Exemplo n.º 7
0
 def test_unicode(self):
     bk = models.BuildingKind(name=models.PERSONALITY)
     self.assertNotEqual(unicode(bk), '')