Ejemplo n.º 1
0
    def test_territory_take_a_random_unit(self):
        territory = Territory()
        troop = Troop(territory=territory)
        cavalry = Cavalry(territory=territory)

        self.assertEqual(troop, territory.take_unit(Troop))
        self.assertEqual(cavalry, territory.take_unit(Cavalry))
Ejemplo n.º 2
0
    def test_taking_negative_units_is_rejected(self):
        territory = Territory()

        for i in range(10):
            Troop(territory=territory)

        with self.assertRaises(ValueError):
            territory.take_unit(Troop, -1)
Ejemplo n.º 3
0
    def test_taking_more_units_than_present_is_rejected(self):
        territory = Territory()

        for i in range(10):
            Troop(territory=territory)

        with self.assertRaises(InsufficientUnitsException):
            territory.take_unit(Troop, 12)
Ejemplo n.º 4
0
    def test_taking_zero_units_is_permitted(self):
        territory = Territory()

        for i in range(10):
            Troop(territory=territory)

        self.assertEqual([], territory.take_unit(Troop, 0))

        empty_territory = Territory()
        self.assertEqual([], empty_territory.take_unit(Troop, 0))