This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/tests/test_basic.py

101 lines
2.9 KiB
Python
Raw Normal View History

2018-04-27 17:16:43 +00:00
import pytest
2018-04-10 15:06:39 +00:00
from ereuse_devicehub.client import Client
2022-04-29 16:23:05 +00:00
from ereuse_devicehub.devicehub import Devicehub
2018-04-27 17:16:43 +00:00
@pytest.mark.mvp
def test_dummy(_app: Devicehub):
"""Tests the dummy cli command."""
runner = _app.test_cli_runner()
runner.invoke('dummy', '--yes')
with _app.app_context():
_app.db.drop_all()
@pytest.mark.mvp
2018-04-27 17:16:43 +00:00
def test_dependencies():
with pytest.raises(ImportError):
# Simplejson has a different signature than stdlib json
# should be fixed though
# noinspection PyUnresolvedReferences
import simplejson
2018-04-10 15:06:39 +00:00
# noinspection PyArgumentList
@pytest.mark.mvp
def test_api_docs(client: Client):
"""Tests /apidocs correct initialization."""
docs, _ = client.get('/apidocs')
assert set(docs['paths'].keys()) == {
2022-04-29 16:23:05 +00:00
'/',
'/actions/',
2021-02-11 20:04:18 +00:00
'/allocates/',
2022-04-29 16:23:05 +00:00
'/apidocs',
2021-02-11 20:04:18 +00:00
'/deallocates/',
'/deliverynotes/',
'/devices/',
'/devices/static/{filename}',
'/documents/actions/',
2022-04-29 16:23:05 +00:00
'/documents/check/',
2021-02-11 20:04:18 +00:00
'/documents/devices/',
2022-04-29 16:23:05 +00:00
'/documents/erasures/',
2021-02-19 11:53:42 +00:00
'/documents/internalstats/',
2021-02-11 20:04:18 +00:00
'/documents/lots/',
2022-04-29 16:23:05 +00:00
'/documents/stamps/',
'/documents/static/{filename}',
'/documents/stock/',
'/documents/wbconf/{wbtype}',
'/inventory/action/add/',
'/inventory/action/allocate/add/',
'/inventory/action/datawipe/add/',
'/inventory/action/trade/add/',
'/inventory/device/',
'/inventory/device/add/',
'/inventory/device/{id}/',
'/inventory/export/{export_id}/',
'/inventory/lot/add/',
'/inventory/lot/{id}/',
'/inventory/lot/{id}/del/',
'/inventory/lot/{lot_id}/device/',
'/inventory/lot/{lot_id}/device/add/',
'/inventory/lot/{lot_id}/trade-document/add/',
'/inventory/lot/{lot_id}/upload-snapshot/',
'/inventory/tag/devices/add/',
'/inventory/tag/devices/{id}/del/',
'/inventory/upload-snapshot/',
'/labels/',
'/labels/add/',
'/labels/print',
'/labels/unnamed/add/',
'/labels/{id}/',
2021-02-11 20:04:18 +00:00
'/licences/',
'/lives/',
2022-04-29 16:23:05 +00:00
'/login/',
'/logout/',
'/lots/',
'/lots/{id}/children',
'/lots/{id}/devices',
2022-04-29 16:23:05 +00:00
'/manufacturers/',
2021-02-11 20:04:18 +00:00
'/metrics/',
2022-04-29 16:23:05 +00:00
'/profile/',
'/set_password/',
'/tags/',
'/tags/{tag_id}/device/{device_id}',
2021-05-21 11:16:06 +00:00
'/trade-documents/',
'/users/',
2021-03-02 20:53:15 +00:00
'/users/login/',
'/users/logout/',
2022-04-29 16:23:05 +00:00
'/versions/',
}
assert docs['info'] == {'title': 'Devicehub', 'version': '0.2'}
assert docs['components']['securitySchemes']['bearerAuth'] == {
'description': 'Basic scheme with token.',
'in': 'header',
'description:': 'HTTP Basic scheme',
'type': 'http',
'scheme': 'basic',
2022-04-29 16:23:05 +00:00
'name': 'Authorization',
}
2021-10-18 09:47:55 +00:00
assert len(docs['definitions']) == 132