def test_ok(self): '''Test status of a good robot object.''' robot = Robot("status_test_robot", "123") action = StatusAction() result = action.do_action(robot, []) self.assertEqual(result['alive'], robot.get_alive())
def test_ok(self): '''Adds a good robot object to the world.''' database = MemcachedDatabase() robot = Robot("world_ok_robot_38364", "123") self._world.add_robot(robot, (5, 0)) database.commit() gotted_robot = database.get_robot(robot.get_id()) self.assertEqual(gotted_robot.get_alive(), robot.get_alive()) all_robots = database.get_all_robot_ids() self.assertIn(robot.get_id(), all_robots)
def test_simple_add(self): '''Test adding a single robot to database.''' database = MemcachedDatabase() new_robot = Robot("test_simple_add_", "123") # No exception should be raise. database.add_robot(new_robot, (0, 0)) database.commit() gotted_robot = database.get_robot("test_simple_add_") self.assertEqual(gotted_robot.get_id(), new_robot.get_id()) self.assertEqual(gotted_robot.get_alive(), new_robot.get_alive()) self.assertEqual(gotted_robot.get_password(), new_robot.get_password())