Skip to content
Snippets Groups Projects
Commit 944205d4 authored by robban64's avatar robban64
Browse files

fix: single items response

parent f08baf88
No related branches found
No related tags found
1 merge request!43Resolve "Implement marshmallow"
...@@ -37,7 +37,7 @@ def list_response(items, total=None, code=200): ...@@ -37,7 +37,7 @@ def list_response(items, total=None, code=200):
def item_response(item, code=200): def item_response(item, code=200):
if isinstance(item, list): if isinstance(item, list):
abort(codes.INTERNAL_SERVER_ERROR) abort(codes.INTERNAL_SERVER_ERROR)
return {"items": [item], "count": 1, "total_count": 1}, code return item, code
from flask_restx import Api from flask_restx import Api
......
...@@ -46,12 +46,12 @@ def test_competition(client): ...@@ -46,12 +46,12 @@ def test_competition(client):
data = {"name": "c1", "year": 2020, "city_id": 1, "style_id": 1} data = {"name": "c1", "year": 2020, "city_id": 1, "style_id": 1}
response, body = post(client, "/api/competitions", data, headers=headers) response, body = post(client, "/api/competitions", data, headers=headers)
assert response.status_code == 200 assert response.status_code == 200
assert body["items"][0]["name"] == "c1" assert body["name"] == "c1"
# Get competition # Get competition
response, body = get(client, "/api/competitions/1", headers=headers) response, body = get(client, "/api/competitions/1", headers=headers)
assert response.status_code == 200 assert response.status_code == 200
assert body["items"][0]["name"] == "c1" assert body["name"] == "c1"
response, body = post(client, "/api/competitions/1/slides", {}, headers=headers) response, body = post(client, "/api/competitions/1/slides", {}, headers=headers)
assert response.status_code == 200 assert response.status_code == 200
...@@ -87,9 +87,9 @@ def test_app(client): ...@@ -87,9 +87,9 @@ def test_app(client):
register_data = {"email": "test1@test.se", "password": "abc123", "role_id": 2, "city_id": 1} register_data = {"email": "test1@test.se", "password": "abc123", "role_id": 2, "city_id": 1}
response, body = post(client, "/api/auth/signup", register_data, headers) response, body = post(client, "/api/auth/signup", register_data, headers)
assert response.status_code == 200 assert response.status_code == 200
assert body["items"][0]["id"] == 2 assert body["id"] == 2
assert "password" not in body["items"][0] assert "password" not in body
assert "_password" not in body["items"][0] assert "_password" not in body
# Try loggin with wrong PASSWORD # Try loggin with wrong PASSWORD
response, body = post(client, "/api/auth/login", {"email": "test1@test.se", "password": "abc1234"}) response, body = post(client, "/api/auth/login", {"email": "test1@test.se", "password": "abc1234"})
...@@ -107,12 +107,12 @@ def test_app(client): ...@@ -107,12 +107,12 @@ def test_app(client):
# Get the current user # Get the current user
response, body = get(client, "/api/users", headers=headers) response, body = get(client, "/api/users", headers=headers)
assert response.status_code == 200 assert response.status_code == 200
assert body["items"][0]["email"] == "test1@test.se" assert body["email"] == "test1@test.se"
# Edit current user name # Edit current user name
response, body = put(client, "/api/users", {"name": "carl carlsson"}, headers=headers) response, body = put(client, "/api/users", {"name": "carl carlsson"}, headers=headers)
assert response.status_code == 200 assert response.status_code == 200
assert body["items"][0]["name"] == "Carl Carlsson" assert body["name"] == "Carl Carlsson"
# Delete created user # Delete created user
response, body = delete(client, "/api/auth/delete/1", {}, headers=headers) response, body = delete(client, "/api/auth/delete/1", {}, headers=headers)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment