def test_delete_docking_station(self): docking_station = DockingStation.create(-90.350, -1.133) docking_station_id = docking_station.id self.assertIsNotNone(docking_station) docking_station.delete() db_docking_station = DockingStation.get(docking_station_id) self.assertIsNone(db_docking_station)
def test_create_docking_station(self): longitude = -90.200391 latitude = -1.163508 docking_station = DockingStation.create(longitude, latitude) db_docking_station = DockingStation.get(docking_station.id) self.assertIsNotNone(db_docking_station) self.assertEqual(db_docking_station.longitude, longitude) self.assertEqual(db_docking_station.latitude, latitude) self.assertIsNotNone(db_docking_station.created_ts) self.assertIsNone(db_docking_station.modified_ts) self.assertEqual((type(db_docking_station.geo)), WKBElement)
def test_get_all_in_radius(self): target_longitude = -75.4980 target_latitude = 12.1897 for points in self._get_waypoints(): DockingStation.create(points[0], points[1]) radius500 = DockingStation.get_all_in_radius(target_longitude, target_latitude, 500) radius450 = DockingStation.get_all_in_radius(target_longitude, target_latitude, 450) radius300 = DockingStation.get_all_in_radius(target_longitude, target_latitude, 300) radius290 = DockingStation.get_all_in_radius(target_longitude, target_latitude, 290) radius100 = DockingStation.get_all_in_radius(target_longitude, target_latitude, 100) radius0 = DockingStation.get_all_in_radius(target_longitude, target_latitude, 0) self.assertEqual(len(radius500), 8) self.assertEqual(len(radius450), 7) self.assertEqual(len(radius300), 6) self.assertEqual(len(radius290), 3) self.assertEqual(len(radius100), 1) self.assertEqual(len(radius0), 0)
def test_create_docking_station_with_incomplete_args(self): longitude = -91.200391 docking_station = None with self.assertRaises(TypeError): docking_station = DockingStation.create(longitude) self.assertIsNone(docking_station)
def test_update_robot_at_docking_station_to_new_docking_station(self): robot = Robot.create(None, self.docking_station.id) new_docking_station = DockingStation.create(-44, -11) robot.update(docking_station_id=new_docking_station.id) self.assertEqual(robot.docking_station_id, new_docking_station.id) self.assertIsNone(robot.route_id)
def tearDown(self): for robot in Robot.get_all(): robot.delete() for docking_station in DockingStation.get_all(): docking_station.delete() for route in Route.get_all(): route.delete() for robot_route in RobotRoute.get_all(): robot_route.delete()
def test_update_docking_station(self): original_latitude = -1.362549 original_longitude = -90.337096 original_docking_station = DockingStation.create( original_longitude, original_latitude) original_geo = original_docking_station.geo self.assertIsNone(original_docking_station.modified_ts) new_latitude = -1.054879 updated_docking_station = original_docking_station.update( latitude=new_latitude) self.assertEqual(updated_docking_station.latitude, new_latitude) self.assertEqual(updated_docking_station.longitude, original_longitude) self.assertNotEqual(updated_docking_station.geo, original_geo) self.assertIsNotNone(updated_docking_station.modified_ts)
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 test_get_nonexistent_docking_station(self): docking_station = DockingStation.get(100) self.assertIsNone(docking_station)
def test_get_docking_station(self): docking_station = DockingStation.create(-90.3370, -1.3625) docking_station_id = docking_station.id db_docking_station = DockingStation.get(docking_station_id) self.assertEqual(db_docking_station.id, docking_station_id)
def test_get_all_in_route_radius(self): route = self._create_route() DockingStation.create(-85.0341, -43.1330) DockingStation.create(-86.7480, -22.6748) DockingStation.create(-73.7402, -22.4719) DockingStation.create(-114.6972, 11.3507) radius0 = DockingStation.get_all_in_route_radius(route, 0) radius400 = DockingStation.get_all_in_route_radius(route, 400) radius700 = DockingStation.get_all_in_route_radius(route, 700) radius2500 = DockingStation.get_all_in_route_radius(route, 2500) self.assertEqual(len(radius0), 1) # should return docking_station on route self.assertEqual(len(radius400), 2) self.assertEqual(len(radius700), 3) self.assertEqual(len(radius2500), 4)
def setUp(self): self.docking_station = DockingStation.create(-74.0478, 12.4687) self.docking_station2 = DockingStation.create(-80.4199, 10.9196) self.docking_station3 = DockingStation.create(80.4199, -10.9196) self.docking_station_schema = DockingStationSchema()
def setUp(self): self.route = Route.create([[-79, 14], [-78, 15]]) self.docking_station = DockingStation.create(-80, 14)