1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-11-22 06:15:02 +01:00

tests/test_api.py: Format with black

This commit is contained in:
Alan Orth 2019-12-14 12:39:58 +02:00
parent 440b2f2dfa
commit 92146fe426
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -11,57 +11,57 @@ def client():
def test_get_docs(client): def test_get_docs(client):
'''Test requesting the documentation at the root.''' """Test requesting the documentation at the root."""
response = client.simulate_get('/') response = client.simulate_get("/")
assert isinstance(response.content, bytes) assert isinstance(response.content, bytes)
assert response.status_code == 200 assert response.status_code == 200
def test_get_item(client): def test_get_item(client):
'''Test requesting a single item.''' """Test requesting a single item."""
response = client.simulate_get('/item/17') response = client.simulate_get("/item/17")
response_doc = json.loads(response.text) response_doc = json.loads(response.text)
assert isinstance(response_doc['downloads'], int) assert isinstance(response_doc["downloads"], int)
assert isinstance(response_doc['id'], int) assert isinstance(response_doc["id"], int)
assert isinstance(response_doc['views'], int) assert isinstance(response_doc["views"], int)
assert response.status_code == 200 assert response.status_code == 200
def test_get_missing_item(client): def test_get_missing_item(client):
'''Test requesting a single non-existing item.''' """Test requesting a single non-existing item."""
response = client.simulate_get('/item/1') response = client.simulate_get("/item/1")
assert response.status_code == 404 assert response.status_code == 404
def test_get_items(client): def test_get_items(client):
'''Test requesting 100 items.''' """Test requesting 100 items."""
response = client.simulate_get('/items', query_string='limit=100') response = client.simulate_get("/items", query_string="limit=100")
response_doc = json.loads(response.text) response_doc = json.loads(response.text)
assert isinstance(response_doc['currentPage'], int) assert isinstance(response_doc["currentPage"], int)
assert isinstance(response_doc['totalPages'], int) assert isinstance(response_doc["totalPages"], int)
assert isinstance(response_doc['statistics'], list) assert isinstance(response_doc["statistics"], list)
assert response.status_code == 200 assert response.status_code == 200
def test_get_items_invalid_limit(client): def test_get_items_invalid_limit(client):
'''Test requesting 100 items with an invalid limit parameter.''' """Test requesting 100 items with an invalid limit parameter."""
response = client.simulate_get('/items', query_string='limit=101') response = client.simulate_get("/items", query_string="limit=101")
assert response.status_code == 400 assert response.status_code == 400
def test_get_items_invalid_page(client): def test_get_items_invalid_page(client):
'''Test requesting 100 items with an invalid page parameter.''' """Test requesting 100 items with an invalid page parameter."""
response = client.simulate_get('/items', query_string='page=-1') response = client.simulate_get("/items", query_string="page=-1")
assert response.status_code == 400 assert response.status_code == 400