def test_delete_cost(self, client): cost = CostFactory.create() url = app.url_path_for('delete_cost', cost_id=cost.id) response = client.delete(url) assert response.status_code == HTTPStatus.NO_CONTENT assert list(Cost.select()) == []
def test_delete_action(self, client): action = ActionFactory.create() url = app.url_path_for('delete_action', action_id=action.id) response = client.delete(url) assert response.status_code == HTTPStatus.NO_CONTENT assert list(Action.select()) == []
def test_delete_message(self, client): message = MessageFactory.create() url = app.url_path_for('delete_message', message_id=message.id) response = client.delete(url) assert response.status_code == HTTPStatus.NO_CONTENT assert list(Message.select()) == []
def test_delete_photo(self, client): photo = PhotoFactory.create() url = app.url_path_for('delete_photo', photo_id=photo.id) response = client.delete(url) assert response.status_code == HTTPStatus.NO_CONTENT assert list(Photo.select()) == []
def test_update_action(self, client): action = ActionFactory.create() user = UserFactory.create() url = app.url_path_for('update_action', action_id=str(action.id)) response = client.patch(url, json={'like_to_user':str(user.id), 'user':str(action.user.id)}) assert response.status_code == HTTPStatus.OK assert response.json()['data']['like_to_user']['id'] == str(user.id)
def test_get_costs(self, client): CostFactory.create_batch(size=3) url = app.url_path_for('get_costs') response = client.get(url) assert response.status_code == HTTPStatus.OK assert response.json()['data']
def test_update_cost(self, client): cost = CostFactory.create() url = app.url_path_for('update_cost', cost_id=str(cost.id)) response = client.patch(url, json={ 'name': 'хлеб', 'user': str(cost.user.id) }) assert response.status_code == HTTPStatus.OK assert response.json()['data']['name'] == 'хлеб'
def test_create_cost(self, client): user = UserFactory.create() self.data.update({'user': str(user.id)}) url = app.url_path_for('create_cost') response = client.post(url, json=self.data) assert response.status_code == HTTPStatus.CREATED cost = Cost.get() assert cost.user.id
def test_create_action_like(self, client): first_user = UserFactory.create() second_user = UserFactory.create() self.data.update({'user':str(first_user.id), 'like_to_user':str(second_user.id), 'dislike_to_user':None}) url = app.url_path_for('create_action') response = client.post(url, json=self.data) assert response.status_code == HTTPStatus.CREATED action = Action.get() assert action.user.id
def test_update_message(self, client): message = MessageFactory.create() message2 = MessageFactory.create() url = app.url_path_for('update_message', message_id=str(message2.id)) response = client.patch(url, json={ 'text': 'aaaa', 'user': str(message2.user.id) }) assert response.status_code == HTTPStatus.OK assert response.json()['data']['text'] == 'aaaa'
def test_create_photo(self, client, image): user = UserFactory.create() url = app.url_path_for('create_photo') multipart_form_data = { 'image': ('image.jpg', image), 'user': (None, str(user.id)), 'is_main': (None, 'false') } response = client.post(url, files=multipart_form_data) assert response.status_code == HTTPStatus.CREATED photo = Photo.get() assert photo.id
def test_create_message(self, client): first_user = UserFactory.create() second_user = UserFactory.create() self.data.update({ 'user': str(first_user.id), 'to_user': str(second_user.id) }) url = app.url_path_for('create_message') response = client.post(url, json=self.data) assert response.status_code == HTTPStatus.CREATED message = Message.get() assert message.text == self.data['text']