2018-04-27 17:16:43 +00:00
|
|
|
import pytest
|
2018-04-10 15:06:39 +00:00
|
|
|
|
2020-07-07 15:17:41 +00:00
|
|
|
from ereuse_devicehub.devicehub import Devicehub
|
2018-06-24 14:57:49 +00:00
|
|
|
from ereuse_devicehub.client import Client
|
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
|
|
|
|
import simplejson
|
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()) == {
|
2020-07-15 11:11:50 +00:00
|
|
|
'/actions/',
|
2018-06-24 14:57:49 +00:00
|
|
|
'/apidocs',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/batteries/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/bikes/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/cameras/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/cellphones/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/components/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/computer-accessories/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/computer-monitors/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/computers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/cookings/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/data-storages/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/dehumidifiers/{dev1_id}/merge/{dev2_id}',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/deliverynotes/',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/desktops/{dev1_id}/merge/{dev2_id}',
|
2018-06-24 14:57:49 +00:00
|
|
|
'/devices/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/devices/static/{filename}',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/devices/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/displays/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/diy-and-gardenings/{dev1_id}/merge/{dev2_id}',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/documents/devices/',
|
2021-01-08 16:37:52 +00:00
|
|
|
'/documents/actions/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/documents/erasures/',
|
2020-08-18 17:19:18 +00:00
|
|
|
'/documents/lots/',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/documents/static/{filename}',
|
2020-08-04 08:27:49 +00:00
|
|
|
'/documents/stock/',
|
2020-12-21 12:53:48 +00:00
|
|
|
'/documents/check/',
|
2021-01-18 11:40:31 +00:00
|
|
|
'/documents/stamps/',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/drills/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/graphic-cards/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/hard-drives/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/homes/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/hubs/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/keyboards/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/label-printers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/laptops/{dev1_id}/merge/{dev2_id}',
|
2018-09-11 19:50:40 +00:00
|
|
|
'/lots/',
|
|
|
|
'/lots/{id}/children',
|
2018-09-20 09:51:25 +00:00
|
|
|
'/lots/{id}/devices',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/manufacturers/',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/memory-card-readers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/mice/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/microphones/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/mixers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/mobiles/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/monitors/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/motherboards/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/network-adapters/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/networkings/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/pack-of-screwdrivers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/printers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/processors/{dev1_id}/merge/{dev2_id}',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/proofs/',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/rackets/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/ram-modules/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/recreations/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/routers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/sais/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/servers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/smartphones/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/solid-state-drives/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/sound-cards/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/sounds/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/stairs/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/switches/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/tablets/{dev1_id}/merge/{dev2_id}',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/tags/',
|
2018-10-16 06:46:55 +00:00
|
|
|
'/tags/{tag_id}/device/{device_id}',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/television-sets/{dev1_id}/merge/{dev2_id}',
|
2020-07-15 11:11:50 +00:00
|
|
|
'/users/',
|
|
|
|
'/users/login/',
|
2020-10-28 20:57:24 +00:00
|
|
|
'/video-scalers/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/videoconferences/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/videos/{dev1_id}/merge/{dev2_id}',
|
|
|
|
'/wireless-access-points/{dev1_id}/merge/{dev2_id}',
|
2020-11-23 17:08:40 +00:00
|
|
|
'/versions/',
|
2020-11-23 10:43:30 +00:00
|
|
|
'/allocates/',
|
|
|
|
'/deallocates/',
|
2020-11-23 17:34:44 +00:00
|
|
|
'/metrics/',
|
2020-12-29 18:03:36 +00:00
|
|
|
'/licences/',
|
|
|
|
'/lives/',
|
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',
|
|
|
|
'name': 'Authorization'
|
|
|
|
}
|
2021-02-10 10:01:12 +00:00
|
|
|
assert len(docs['definitions']) == 123
|