def change_wrist(body): """ Set wrist location :param body: Location object :type body: dict | bytes :rtype: Location """ if connexion.request.is_json: body = Location.from_dict(connexion.request.get_json()) location = body.location AX12.wrist(location) return Location(location)
def read_grip(): """ Get grip location :rtype: Location """ location = AX12.get_grip() return Location(location)
def read_wrist(): """ Get wrist location :rtype: Location """ location = AX12.get_wrist() return Location(location)
def read_elbow(): """ Get elbow location :rtype: Location """ location = AX12.get_elbow() return Location(location)
def read_pivot(): """ Get pivot location :rtype: Location """ location = AX12.get_pivot() return Location(location)
def read_shoulder(): """ Get shoulder location :rtype: Location """ location = AX12.get_shoulder() return Location(location)
def read_hand(): """ Get hand location :rtype: Location """ location = AX12.get_hand() return Location(location)
def test_change_shoulder(self): """ Test case for change_shoulder Set shoulder location """ body = Location() response = self.client.open('/v1/arm/shoulder', method='PUT', data=json.dumps(body), content_type='application/json') self.assert200(response, "Response body is : " + response.data.decode('utf-8'))
def create_location(event, context): user = event['requestContext']['authorizer']['principalId'] location = Location.from_dict(json.loads(event["body"])) value, retcode = location_controller.create_location( location, user, location_controller.authorizer(event['requestContext']['authorizer'])) value.location_id = str(value.location_id) return create_response(event, retcode, value)
def delete_location(event, context): user = event['requestContext']['authorizer']['principalId'] if 'pathParameters' in event: location_id = event["pathParameters"]["location_id"] location = Location.from_dict(json.loads(event["body"])) value, retcode = location_controller.delete_location( location_id, user, location_controller.authorizer(event['requestContext']['authorizer'])) return create_response(event, retcode, value)
def test_add_location(self, mocked_insert_new_location): """Test case for add_location Add a new user location to the system """ body = Location("kitchen") mocked_insert_new_location.assert_not_called() mocked_insert_new_location.return_value = None response = self.client.open('/location', data=json.dumps(body), method='POST', content_type='application/json') mocked_insert_new_location.assert_called_once() self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def add_location(location): # noqa: E501 """Add a new user location to the system Add a new location of the user # noqa: E501 :param location: :type location: dict | bytes :rtype: str """ if connexion.request.is_json: location = Location.from_dict( connexion.request.get_json()) # noqa: E501 db = PostgresDB() error = db.insert_new_location(location.location) if error: return jsonify(msg=error) return jsonify(msg='Human detected at %s' % location.location)