Skip to content

Commit

Permalink
update api and collection import tests
Browse files Browse the repository at this point in the history
  • Loading branch information
briantist committed Oct 8, 2023
1 parent 881d539 commit bac1e33
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions tests/unit/client/test_api.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
# -*- coding: utf-8 -*-
# (c) 2022 Brian Scholer (@briantist)

import pytest
from galactory import constants as C
from galactory.api import API_RESPONSE

from datetime import datetime

def test_api(client, trailer):
@pytest.mark.parametrize('app', [
dict(API_VERSION=['v2']),
dict(API_VERSION=['v3']),
dict(API_VERSION=['v3', 'v2']),
None,
], indirect=True)
def test_api(app, client, trailer):
response = client.get(trailer('/api'))
data = response.json

possible_versions = ('v2', 'v3')
api_config = app.config.get('API_VERSION')
active_versions = api_config or possible_versions

assert response.status_code == C.HTTP_OK
assert data == API_RESPONSE
assert 'v2' in data['available_versions']
assert 'v2' == data['current_version']
assert 'available_versions' in data

if 'v2' in active_versions:
assert data['current_version'] == 'v2'
else:
assert 'current_version' not in data

for v in active_versions:
assert v in possible_versions
assert v in data['available_versions']
assert data['available_versions'][v] == f"{v}/"


def test_import_collection_status(client, trailer):
response = client.get(trailer('/api/v2/collection-imports/0'))
@pytest.mark.parametrize(['app', 'path'], [
(dict(API_VERSION=['v2']), 'collection-imports/0'),
(dict(API_VERSION=['v3']), 'imports/collections/0'),
], indirect=['app'])
def test_import_collection_status(app, path, client, trailer):
active_version = app.config['API_VERSION'][0]
response = client.get(trailer(f"/api/{active_version}/{path}"))
data = response.json

assert response.status_code == C.HTTP_OK
Expand Down

0 comments on commit bac1e33

Please sign in to comment.