def test_delete_route(self): route = Route.create(self.points) route_id = route.id self.assertIsNotNone(route) route.delete() db_route = Route.get(route_id) self.assertIsNone(db_route)
def test_get_all_docking_stations_in_radius_of_route(self): route = Route.create([[-75.4980, 12.1897], [-75.4990, 12.1900]]) json_data = json.dumps({'radius': 500, 'route_id': route.id}) response = self.client.get(BASE_URL, query_string=json_data) data = json.loads(response.get_data()) self.assertEqual(len(data), 2) self.assertEqual(response.status_code, 200)
def _create_robot_routes(self): robot = Robot.create(self.route.id, None) robot.robot_routes[-1].delete() route_1 = Route.create([[-13, 15], [-13, 14]]) route_2 = Route.create([[-11, 15], [-12, 14]]) route_3 = Route.create([[-10, 15], [-11, 14]]) route_4 = Route.create([[-10, 14], [-11, 14]]) t1 = datetime(2018, 1, 1) t2 = datetime(2018, 3, 3) t3 = datetime(2018, 5, 27) t4 = datetime(2018, 10, 11) t5 = datetime(2018, 10, 12) t6 = datetime(2019, 1, 3) t7 = datetime(2019, 2, 2) t8 = datetime(2019, 5, 9) t9 = datetime(2019, 6, 6) robot_route_1 = RobotRoute.create(robot.id, self.route.id, t1) robot_route_1.update(t2) robot_route_2 = RobotRoute.create(robot.id, route_1.id, t3) robot_route_2.update(t4) robot_route_3 = RobotRoute.create(robot.id, route_2.id, t5) robot_route_3.update(t6) robot_route_4 = RobotRoute.create(robot.id, route_3.id, t7) robot_route_4.update(t8) robot_route_5 = RobotRoute.create(robot.id, route_4.id, t9) return { 'robot': robot, 'robot_route_1_route_id': robot_route_1.route_id, 'robot_route_2_route_id': robot_route_2.route_id, 'robot_route_3_route_id': robot_route_3.route_id, 'robot_route_4_route_id': robot_route_4.route_id, 'robot_route_5_route_id': robot_route_5.route_id }
def test_create_route(self): route = Route.create(self.points) db_route = Route.get(route.id) self.assertIsNotNone(db_route.path) self.assertEqual(type(db_route.path), WKBElement) self.assertIsNotNone(db_route.created_ts) self.assertIsNone(db_route.modified_ts) self.assertEqual(db_route.robots, [])
def test_update_route(self): route = Route.create(self.points) original_path = route.path original_points = route.points self.assertIsNone(route.modified_ts) new_points = [[-1.3223, -14.3221], [-1.0531, -15.3221]] route.update(new_points) self.assertNotEqual(route.path, original_path) self.assertNotEqual(route.points, original_points) self.assertIsNotNone(route.modified_ts)
def test_update_robot_on_route_to_new_route(self): robot = Robot.create(self.route.id, None) old_robot_route = robot.current_robot_route() new_route = Route.create([[-11, -11], [9, 19], [10, 15]]) robot.update(route_id=new_route.id) updated_robot_route = robot.current_robot_route() self.assertEqual(robot.route_id, new_route.id) self.assertNotEqual(old_robot_route, updated_robot_route) self.assertIsNotNone(old_robot_route.end_ts) self.assertIsNone(updated_robot_route.end_ts) self.assertTrue(robot in new_route.robots) self.assertIsNone(robot.docking_station_id)
def test_get_route(self): route = Route.create(self.points) route_id = route.id db_route = Route.get(route_id) self.assertEqual(db_route.id, route_id)
def setUp(self): self.docking_station = DockingStation.create(-74.0478, 12.4687) self.route = Route.create([[-75.10, 12.50], [-81.42, 10.92]]) self.robot_schema = RobotSchema() self.robot = Robot.create(self.route.id, None)
def _create_route(self): points = [[-79.6289, -10.7901], [-77.0800, -16.5098], [-73.7402, -22.4719], [-75.4980, -30.6757], [-81.9140, -36.9147]] return Route.create(points)
def setUp(self): self.route = Route.create([[-74.0478, 12.4687], [-80.4199, 10.9196]]) self.route2 = Route.create([[-75.0478, 12.4687], [-81.4199, 10.9196]]) self.route_schema = RouteSchema()
def setUp(self): self.route = Route.create([[-79, 14], [-78, 15]]) self.docking_station = DockingStation.create(-80, 14)
def create(**kwargs): Route.abort_repeat(msg='唯一键重复', name=kwargs['name']) Route.create(**kwargs)