Пример #1
0
    def test_same_realm(self):
        realm = Realm()
        army = Army(0, realm)
        province = Province(None, 0, 0)
        province.add_army(army)
        realm.add_province(province)

        self.assertFalse(can_create_province(realm, army))
Пример #2
0
 def test_invalid_size(self):    
     realm = Realm()        
     province = Province(None, 0,0)
     realm.add_province(province)
     
     self.assertRaises(AssertionError, can_create_army, realm, province, 0)
     self.assertRaises(AssertionError, can_create_army, realm, province, -1)
     self.assertRaises(AssertionError, can_create_army, realm, province, None)
Пример #3
0
    def test_other_realm(self):
        realm0 = Realm()
        realm1 = Realm()
        army = Army(0, realm0)
        province = Province(None, 0, 0)
        province.add_army(army)
        realm1.add_province(province)

        self.assertFalse(can_create_province(realm0, army))
Пример #4
0
 def test_second_time(self):    
     realm = Realm()
     
     province = Province(None, 0,0)
     self.assertTrue(realm.add_province(province))    
     self.assertFalse(realm.add_province(province))
     self.assertTrue(province in realm.provinces)
     self.assertEqual(province.realm, realm)
     self.assertEqual(len(realm.provinces), 1)
Пример #5
0
 def test_add_province(self):
     realm = Realm()
     
     province = Province(None, 0,0)
     self.assertTrue(realm.add_province(province))
     self.assertEqual(len(realm.provinces), 1)
     self.assertEqual(province.realm, realm)
     self.assertTrue(province in realm.provinces)
     
     province = Province(None, 1,0)
     self.assertTrue(realm.add_province(province))
     self.assertEqual(len(realm.provinces), 2)
     self.assertEqual(province.realm, realm)
     self.assertTrue(province in realm.provinces)
 def test_remove_province(self):
     realm = Realm()
     
     province0 = Province(None, 0,0)
     realm.add_province(province0)
     
     province1 = Province(None, 1,0)
     realm.add_province(province1)
     
     self.assertTrue(realm.remove_province(province0))        
     self.assertEqual(len(realm.provinces), 1)
     self.assertEqual(province0.realm, None)
     self.assertFalse(province0 in realm.provinces)
     
     self.assertTrue(realm.remove_province(province1))        
     self.assertEqual(len(realm.provinces), 0)
     self.assertEqual(province1.realm, None)
     self.assertFalse(province1 in realm.provinces)
Пример #7
0
 def test_can_create_army(self):     
     realm = Realm()        
     province = Province(None, 0,0)
     realm.add_province(province)
     
     self.assertTrue(can_create_army(realm, province, 1))