2018-04-27 17:16:43 +00:00
|
|
|
import pytest
|
2018-04-10 15:06:39 +00:00
|
|
|
|
2018-06-24 14:57:49 +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
|
|
|
|
|
|
|
|
2020-07-07 15:17:41 +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
|
2022-05-11 11:14:11 +00:00
|
|
|
import simplejson # noqa: F401
|
2018-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
# noinspection PyArgumentList
|
2020-07-07 15:17:41 +00:00
|
|
|
@pytest.mark.mvp
|
2018-06-24 14:57:49 +00:00
|
|
|
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
|
|
|
'/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/actions/',
|
2021-02-11 20:04:18 +00:00
|
|
|
'/allocates/',
|
2018-06-24 14:57:49 +00:00
|
|
|
'/apidocs',
|
2022-04-08 10:45:35 +00:00
|
|
|
'/api/inventory/',
|
2021-02-11 20:04:18 +00:00
|
|
|
'/deallocates/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/deliverynotes/',
|
2018-06-24 14:57:49 +00:00
|
|
|
'/devices/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/devices/static/{filename}',
|
2021-01-08 16:37:52 +00:00
|
|
|
'/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-11 20:04:18 +00:00
|
|
|
'/documents/lots/',
|
2022-06-02 12:09:21 +00:00
|
|
|
'/inventory/search/',
|
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}/',
|
2022-08-31 15:25:38 +00:00
|
|
|
'/inventory/device/{dhid}/binding/',
|
2022-09-20 11:05:23 +00:00
|
|
|
'/inventory/device/erasure/',
|
2022-11-21 14:35:37 +00:00
|
|
|
'/inventory/device/erasure/{orphans}/',
|
2022-09-09 11:44:51 +00:00
|
|
|
'/inventory/all/device/',
|
2022-04-29 16:23:05 +00:00
|
|
|
'/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/',
|
2022-06-06 11:38:22 +00:00
|
|
|
'/inventory/lot/{lot_id}/deliverynote/',
|
|
|
|
'/inventory/lot/{lot_id}/receivernote/',
|
2022-04-29 16:23:05 +00:00
|
|
|
'/inventory/lot/{lot_id}/trade-document/add/',
|
2022-06-01 12:00:16 +00:00
|
|
|
'/inventory/lot/{lot_id}/transfer/{type_id}/',
|
|
|
|
'/inventory/lot/{lot_id}/transfer/',
|
2022-10-06 15:16:53 +00:00
|
|
|
'/inventory/lot/transfer/{type_id}/',
|
2022-04-29 16:23:05 +00:00
|
|
|
'/inventory/lot/{lot_id}/upload-snapshot/',
|
2022-05-23 07:34:04 +00:00
|
|
|
'/inventory/snapshots/{snapshot_uuid}/',
|
|
|
|
'/inventory/snapshots/',
|
2022-08-31 15:25:38 +00:00
|
|
|
'/inventory/tag/devices/{dhid}/add/',
|
|
|
|
'/inventory/tag/devices/{dhid}/del/',
|
2022-04-29 16:23:05 +00:00
|
|
|
'/inventory/upload-snapshot/',
|
2022-07-12 11:17:13 +00:00
|
|
|
'/inventory/device/edit/{id}/',
|
|
|
|
'/inventory/upload-placeholder/',
|
|
|
|
'/inventory/lot/{lot_id}/upload-placeholder/',
|
|
|
|
'/inventory/placeholder-logs/',
|
2022-08-02 16:01:28 +00:00
|
|
|
'/inventory/unbinding/{phid}/',
|
|
|
|
'/inventory/binding/{dhid}/{phid}/',
|
2022-04-29 16:23:05 +00:00
|
|
|
'/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/',
|
2018-09-11 19:50:40 +00:00
|
|
|
'/lots/',
|
|
|
|
'/lots/{id}/children',
|
2018-09-20 09:51:25 +00:00
|
|
|
'/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/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/tags/',
|
2018-10-16 06:46:55 +00:00
|
|
|
'/tags/{tag_id}/device/{device_id}',
|
2021-05-21 11:16:06 +00:00
|
|
|
'/trade-documents/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/users/',
|
2021-03-02 20:53:15 +00:00
|
|
|
'/users/login/',
|
|
|
|
'/users/logout/',
|
2022-04-29 16:23:05 +00:00
|
|
|
'/versions/',
|
2022-08-12 07:58:19 +00:00
|
|
|
'/workbench/',
|
2022-10-14 13:33:43 +00:00
|
|
|
'/workbench/erasure_host/{id}/',
|
2018-06-24 14:57:49 +00:00
|
|
|
}
|
|
|
|
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',
|
2018-06-24 14:57:49 +00:00
|
|
|
}
|
2022-11-29 16:46:41 +00:00
|
|
|
assert len(docs['definitions']) == 134
|