Пример #1
0
def test_DELETE_request_categories(app):

    with app.test_client() as client:
        response = client.delete('/categories/5')

        data = json.loads(response.data.decode())
        assert response.status_code == 404
Пример #2
0
def test_GET_request_categories(app):

    categories = app.test_client()

    expected = categories.get('/categories').status_code

    result = 200

    assert expected == result
Пример #3
0
def test_GET_request_one_category(app):

    category = app.test_client()

    expected = category.get('/categories/3').status_code

    result = 200

    assert expected == result
Пример #4
0
def test_POST_request_categories(app):

    with app.test_client() as client:
        response = client.post(
            '/categories',
            data=json.dumps(dict(name='Sobremesa', image='url')),
            content_type='application/json',
        )

        data = json.loads(response.data.decode())
        assert response.status_code == 201
Пример #5
0
def test_PATCH_request_categories(app):

    with app.test_client() as client:
        response = client.patch(
            '/categories/3',
            data=json.dumps(dict(name='Porções', )),
            content_type='application/json',
        )

        data = json.loads(response.data.decode())
        assert response.status_code == 200

        assert data == {"id": 3, "name": "Porções"}
Пример #6
0
 def test_home(self):
     test = app.test_client(self)
     response = test.get('/')
     self.assertEqual(response.status_code, 200)
def client(request):
    client = app.test_client()

    return client
def client(request):
    client = app.test_client()

    return client
Пример #9
0
 def client():
     return app.test_client()