def test_second_time(self):
     province = Province(None, 2, 4)
     army = Army(None, 10)
     
     province.add_army(army)
     self.assertTrue(province.remove_army(army))
     self.assertFalse(province.remove_army(army))
     self.assertEqual(len(province.armies), 0)
     self.assertFalse(army in province.armies)
     self.assertEqual(army.province, None)
Example #2
0
 def test_can_move_army(self): 
     realm = Realm()    
     army = Army(0, realm)
     province0 = Province(None, 1, 1)
     province0.add_army(army)
     
     self.assertTrue(can_move_army(realm, army, Province(None, 2, 1)))
     self.assertTrue(can_move_army(realm, army, Province(None, 2, 2)))
     self.assertTrue(can_move_army(realm, army, Province(None, 1, 2)))
     self.assertTrue(can_move_army(realm, army, Province(None, 0, 1)))
     self.assertTrue(can_move_army(realm, army, Province(None, 1, 0)))
     self.assertTrue(can_move_army(realm, army, Province(None, 2, 0)))
     
     province0.remove_army(army)
     province1 = Province(None, 1, 2)
     province1.add_army(army)
     
     self.assertTrue(can_move_army(realm, army, Province(None, 2, 2)))
     self.assertTrue(can_move_army(realm, army, Province(None, 1, 3)))
     self.assertTrue(can_move_army(realm, army, Province(None, 0, 3)))
     self.assertTrue(can_move_army(realm, army, Province(None, 0, 2)))
     self.assertTrue(can_move_army(realm, army, Province(None, 0, 1)))
     self.assertTrue(can_move_army(realm, army, Province(None, 1, 1)))
 def test_remove_army(self):
     province = Province(None, 2, 4)
     army0 = Army(None, 10)
     army1 = Army(None, 10)
     
     province.add_army(army0)
     province.add_army(army1)
     
     self.assertTrue(province.remove_army(army0))
     self.assertTrue(province.remove_army(army1))
     
     self.assertEqual(len(province.armies), 0)
     self.assertFalse(army0 in province.armies)
     self.assertFalse(army1 in province.armies)
     self.assertEqual(army0.province, None)
     self.assertEqual(army1.province, None)