def list_cats(): # noqa: E501 """Retrieves the list of all cats Retrieves the list of all cats # noqa: E501 :rtype: CatsResponse """ return CatsResponse(cats=list( map(lambda x: Cat.from_dict(x), SAMPLE_CAT_STORAGE.values())))
def get_cat(cat_id): # noqa: E501 """Retrieve a single cat Retrieve a single cat # noqa: E501 :param cat_id: Id of the cat desired to be retrieved :type cat_id: str :rtype: Cat """ return Cat.from_dict(SAMPLE_CAT_STORAGE[cat_id])
def test_update_cat(self): """Test case for update_cat Update an existing cat """ cat = Cat() response = self.client.open( '/cats/{cat_id}'.format(cat_id='cat_id_example'), method='PUT', data=json.dumps(cat), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def test_add_cat(self): """Test case for add_cat Add a new cat to the store """ cat = Cat() response = self.client.open( '/cats', method='POST', data=json.dumps(cat), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def add_cat(cat=None): # noqa: E501 """Add a new cat to the store Creates a new cat in the store # noqa: E501 :param cat: Cat object that needs to be added to the store :type cat: dict | bytes :rtype: Cat """ if connexion.request.is_json: cat = Cat.from_dict(connexion.request.get_json()) # noqa: E501 SAMPLE_CAT_STORAGE[cat.id] = cat.to_dict() return cat, 201
def update_cat(cat_id, cat=None): # noqa: E501 """Update an existing cat # noqa: E501 :param cat_id: Id of the cat desired to be updated :type cat_id: str :param cat: Cat object that needs to be added to the store :type cat: dict | bytes :rtype: Cat """ if connexion.request.is_json: cat = Cat.from_dict(connexion.request.get_json()) # noqa: E501 cat.id = cat_id SAMPLE_CAT_STORAGE[cat_id] = cat.to_dict() return cat, 201