Ejemplo n.º 1
0
    def test_get_knowledge_about_object_if_user_move(self, MockMap, MockBrain):
        user = User('User')
        user.brain = MockBrain

        direction = choice(user.directions)
        MockBrain.see.return_value = TREE
        user.move(direction, MockMap)
        user.brain.knowledge.assert_called_with(MockMap, user.position,
                                                direction)
Ejemplo n.º 2
0
    def test_change_direction_if_user_move(self, MockMap, MockBrain):
        user = User('User')
        user.brain = MockBrain
        self.assertEqual(user.direction, DIRECTION_UP)
        user.move(DIRECTION_DOWN, MockMap)
        self.assertEqual(user.direction, DIRECTION_DOWN)

        direction = choice(user.directions)
        user.move(direction, MockMap)
        self.assertEqual(user.direction, direction)
Ejemplo n.º 3
0
    def test_change_position_if_object_not_barier(self, MockMap, MockBrain):
        user = User('User')
        user.brain = MockBrain

        user_position = user.position
        object_position = [randint(0, 100), randint(0, 100)]
        direction = choice(user.directions)
        user.brain.knowledge.return_value = Empty(object_position)
        user.move(direction, MockMap)
        self.assertEqual(user.position, object_position)
        MockMap.move.assert_called_with(USER, user_position, object_position)