Exemple #1
0
    def test_movement_to_non_adjacent_territory_is_invalid(self):
        p1, = self.generate_players(1)
        t1, t2 = self.generate_territories(owners=[p1], complete_graph=False)
        self.generate_troops({t1: 2})
        order = Movement(issuer=p1, origin=t1, destination=t2, num_troops=2)

        with self.assertRaises(TargetTerritoryNotAdjacent):
            order.assert_is_valid()
Exemple #2
0
    def test_movement_with_insufficient_units_is_invalid(self):
        p1, = self.generate_players(1)
        t1, t2 = self.generate_territories(owners=[p1])
        self.generate_troops({t1: 1})
        order = Movement(issuer=p1, origin=t1, destination=t2, num_troops=2)

        with self.assertRaises(InsufficientUnitsException):
            order.assert_is_valid()
Exemple #3
0
 def test_movement_with_all_available_units_is_valid(self):
     p1, = self.generate_players(1)
     t1, t2 = self.generate_territories(owners=[p1])
     self.generate_troops({t1: 3})
     instruction = Movement(issuer=p1,
                            origin=t1,
                            destination=t2,
                            num_troops=3)
     instruction.assert_is_valid()
Exemple #4
0
    def test_movement_with_other_origin_owner_is_invalid(self):
        p1, p2 = self.generate_players()
        t1, t2 = self.generate_territories(owners=[p2])
        self.generate_troops({t1: 1})

        order = Movement(issuer=p1, origin=t1, destination=t2, num_troops=1)

        with self.assertRaises(IssuerDoesNotOwnTerritory):
            order.assert_is_valid()
Exemple #5
0
    def test_movement_can_take_integers_instead_of_territories_if_world_is_set(
            self):
        p1, = self.generate_players(1)
        t1, t2 = self.generate_territories(owners=[p1])
        self.generate_troops({t1: 1})

        order = Movement(issuer=p1,
                         origin=t1.id,
                         destination=t2.id,
                         num_troops=1,
                         world=self.world)
        order.assert_is_valid()

        # Origin and destination are resolved to their respective Territories.
        self.assertEqual(order.origin, t1)
        self.assertEqual(order.destination, t2)