Exemple #1
0
    def test_water_level(self):
        '''Tests if water level increases after watering.'''
        database = MemcachedDatabase()
        world = World()

        robot = Robot("198.1287.fkdfjei", "123")
        robot.set_location((5, 0))
        robot.set_has_water(True)

        plant = Plant()
        plant.set_water_level(30)

        world.plant(plant, (5, 0))

        database.commit()

        action = WaterAction()
        action.do_action(robot, ["198.1287.fkdfjei"])

        database.commit()

        updated_square = world.get_square((5, 0))
        plant = updated_square.get_plant()

        # Checking if honor increased.
        self.assertEqual(robot.get_honor(), 1)

        self.assertEqual(plant.get_water_level(), 100)
        self.assertFalse(robot.get_has_water())
    def test_water_level(self):
        '''Tests if water level increases after watering.'''
        database = MemcachedDatabase()
        world = World()

        robot = Robot("198.1287.fkdfjei", "123")
        robot.set_location((5, 0))
        robot.set_has_water(True)

        plant = Plant()
        plant.set_water_level(30)

        world.plant(plant, (5, 0))

        database.commit()

        action = WaterAction()
        action.do_action(robot, ["198.1287.fkdfjei"])

        database.commit()

        updated_square = world.get_square((5, 0))
        plant = updated_square.get_plant()

        # Checking if honor increased.
        self.assertEqual(robot.get_honor(), 1)

        self.assertEqual(plant.get_water_level(), 100)
        self.assertFalse(robot.get_has_water())
Exemple #3
0
    def test_no_plant_square(self):
        '''Tests watering a square without any plant.'''
        database = MemcachedDatabase()

        robot = Robot("098kk.ski87.99", "123")
        robot.set_location((6, 0))
        robot.set_has_water(True)

        action = WaterAction()

        action.do_action(robot, ["098kk.ski87.99"])

        self.assertFalse(robot.get_has_water())
        # Honor shouldn't increase because this robot didn't really watered a plant.
        self.assertEqual(robot.get_honor(), 0)

        database.rollback()
    def test_no_plant_square(self):
        '''Tests watering a square without any plant.'''
        database = MemcachedDatabase()

        robot = Robot("098kk.ski87.99", "123")
        robot.set_location((6, 0))
        robot.set_has_water(True)

        action = WaterAction()

        action.do_action(robot, ["098kk.ski87.99"])

        self.assertFalse(robot.get_has_water())
        # Honor shouldn't increase because this robot didn't really watered a plant.
        self.assertEqual(robot.get_honor(), 0)

        database.rollback()