Exemplo n.º 1
0
    def test_create_robot_with_docking_station(self, create):
        robot = Robot.create(None, self.docking_station.id)
        db_robot = Robot.get(robot.id)

        create.assert_not_called()
        self.assertIsNotNone(db_robot)
        self.assertIsNotNone(db_robot.created_ts)
        self.assertIsNone(db_robot.modified_ts)
        self.assertIsNone(db_robot.route_id)
        self.assertEqual(db_robot.docking_station_id, self.docking_station.id)
Exemplo n.º 2
0
    def get_all(cls, query_string=None):
        from app.models.robot import Robot

        query_string = json.loads(query_string) if query_string else {}
        if not query_string.get('robot_id'):
            return cls.query.all()

        robot = Robot.get(query_string.get('robot_id'))
        if not robot:
            raise NotFound({
                'resource_name': 'Robot',
                'id': query_string.get('robot_id')
            })

        target_dt, start_dt, end_dt = validate_and_extract_datetimes(
            query_string)

        if target_dt:
            robot.find_route_by_ts(target_dt)

        return robot.find_routes_by_ts_range(start_ts=start_dt, end_ts=end_dt)
Exemplo n.º 3
0
    def test_delete_robot(self):
        robot = Robot.create(None, self.docking_station.id)
        robot.delete()
        robot_db = Robot.get(robot.id)

        self.assertIsNone(robot_db)
Exemplo n.º 4
0
 def test_get_nonexistent_robot(self):
     robot = Robot.get(100)
     self.assertIsNone(robot)
Exemplo n.º 5
0
    def test_get_robot(self):
        robot = Robot.create(None, self.docking_station.id)
        db_robot = Robot.get(robot.id)

        self.assertEqual(db_robot.id, robot.id)