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))
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)
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))
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)
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)
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))