Beispiel #1
0
    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()) == []
Beispiel #2
0
    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()) == []
Beispiel #4
0
    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()) == []
Beispiel #5
0
    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)
Beispiel #6
0
    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']
Beispiel #7
0
    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'] == 'хлеб'
Beispiel #8
0
    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
Beispiel #9
0
    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
Beispiel #10
0
    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'
Beispiel #11
0
    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
Beispiel #12
0
    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']