diff --git a/ereuse_devicehub/resources/device/definitions.py b/ereuse_devicehub/resources/device/definitions.py index 61211ca8..8bac5f97 100644 --- a/ereuse_devicehub/resources/device/definitions.py +++ b/ereuse_devicehub/resources/device/definitions.py @@ -276,6 +276,22 @@ class VideoconferenceDef(VideoDef): SCHEMA = schemas.Videoconference +class CookingDef(DeviceDef): + VIEW = None + SCHEMA = schemas.Cooking + + def __init__(self, app, import_name=__name__, static_folder=None, static_url_path=None, + template_folder=None, url_prefix=None, subdomain=None, url_defaults=None, + root_path=None, cli_commands: Iterable[Tuple[Callable, str or None]] = tuple()): + super().__init__(app, import_name, static_folder, static_url_path, template_folder, + url_prefix, subdomain, url_defaults, root_path, cli_commands) + + +class Mixer(CookingDef): + VIEW = None + SCHEMA = schemas.Mixer + + class ManufacturerDef(Resource): VIEW = ManufacturerView SCHEMA = schemas.Manufacturer diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 23cfcf9e..a13b4de1 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -639,6 +639,14 @@ class Videoconference(Video): pass +class Cooking(Device): + pass + + +class Mixer(Cooking): + pass + + class Manufacturer(db.Model): __table_args__ = {'schema': 'common'} CSV_DELIMITER = csv.get_dialect('excel').delimiter diff --git a/ereuse_devicehub/resources/device/models.pyi b/ereuse_devicehub/resources/device/models.pyi index 2b75f8b7..7a893ad2 100644 --- a/ereuse_devicehub/resources/device/models.pyi +++ b/ereuse_devicehub/resources/device/models.pyi @@ -394,6 +394,14 @@ class Videoconference(Video): pass +class Cooking(Device): + pass + + +class Mixer(Cooking): + pass + + class Manufacturer(Model): CUSTOM_MANUFACTURERS = ... # type: set name = ... # type: Column diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 60bf541c..79f02fe5 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -295,3 +295,11 @@ class VideoScaler(Video): class Videoconference(Video): pass + + +class Cooking(Device): + pass + + +class Mixer(Cooking): + pass diff --git a/tests/test_basic.py b/tests/test_basic.py index 2097967f..6c011238 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -40,4 +40,4 @@ def test_api_docs(client: Client): 'scheme': 'basic', 'name': 'Authorization' } - assert 92 == len(docs['definitions']) + assert 94 == len(docs['definitions']) diff --git a/tests/test_device.py b/tests/test_device.py index c43fa30b..152857b3 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -20,7 +20,8 @@ from ereuse_devicehub.resources.device.exceptions import NeedsId from ereuse_devicehub.resources.device.schemas import Device as DeviceS from ereuse_devicehub.resources.device.sync import MismatchBetweenTags, MismatchBetweenTagsAndHid, \ Sync -from ereuse_devicehub.resources.enums import ComputerChassis, DisplayTech, Severity +from ereuse_devicehub.resources.enums import ComputerChassis, DisplayTech, Severity, \ + SnapshotSoftware from ereuse_devicehub.resources.event import models as m from ereuse_devicehub.resources.event.models import Remove, Test from ereuse_devicehub.resources.tag.model import Tag @@ -536,3 +537,30 @@ def test_networking_model(): switch = d.Switch(speed=1000, wireless=False) db.session.add(switch) db.session.commit() + + +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_cooking_mixer(): + mixer = d.Mixer(serial_number='foo', model='bar', manufacturer='foobar') + db.session.add(mixer) + db.session.commit() + + +def test_cooking_mixer_api(user: UserClient): + snapshot, _ = user.post( + { + 'type': 'Snapshot', + 'device': { + 'serialNumber': 'foo', + 'model': 'bar', + 'manufacturer': 'foobar', + 'type': 'Mixer' + }, + 'version': '11.0', + 'software': SnapshotSoftware.Web.name + }, + res=m.Snapshot + ) + mixer, _ = user.get(res=d.Device, item=snapshot['device']['id']) + assert mixer['type'] == 'Mixer' + assert mixer['serialNumber'] == 'foo'