Add Mixer

This commit is contained in:
Xavier Bustamante Talavera 2018-11-12 11:59:49 +01:00
parent 048a03801b
commit 0ec06808ce
6 changed files with 70 additions and 2 deletions

View file

@ -276,6 +276,22 @@ class VideoconferenceDef(VideoDef):
SCHEMA = schemas.Videoconference 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): class ManufacturerDef(Resource):
VIEW = ManufacturerView VIEW = ManufacturerView
SCHEMA = schemas.Manufacturer SCHEMA = schemas.Manufacturer

View file

@ -639,6 +639,14 @@ class Videoconference(Video):
pass pass
class Cooking(Device):
pass
class Mixer(Cooking):
pass
class Manufacturer(db.Model): class Manufacturer(db.Model):
__table_args__ = {'schema': 'common'} __table_args__ = {'schema': 'common'}
CSV_DELIMITER = csv.get_dialect('excel').delimiter CSV_DELIMITER = csv.get_dialect('excel').delimiter

View file

@ -394,6 +394,14 @@ class Videoconference(Video):
pass pass
class Cooking(Device):
pass
class Mixer(Cooking):
pass
class Manufacturer(Model): class Manufacturer(Model):
CUSTOM_MANUFACTURERS = ... # type: set CUSTOM_MANUFACTURERS = ... # type: set
name = ... # type: Column name = ... # type: Column

View file

@ -295,3 +295,11 @@ class VideoScaler(Video):
class Videoconference(Video): class Videoconference(Video):
pass pass
class Cooking(Device):
pass
class Mixer(Cooking):
pass

View file

@ -40,4 +40,4 @@ def test_api_docs(client: Client):
'scheme': 'basic', 'scheme': 'basic',
'name': 'Authorization' 'name': 'Authorization'
} }
assert 92 == len(docs['definitions']) assert 94 == len(docs['definitions'])

View file

@ -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.schemas import Device as DeviceS
from ereuse_devicehub.resources.device.sync import MismatchBetweenTags, MismatchBetweenTagsAndHid, \ from ereuse_devicehub.resources.device.sync import MismatchBetweenTags, MismatchBetweenTagsAndHid, \
Sync 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 import models as m
from ereuse_devicehub.resources.event.models import Remove, Test from ereuse_devicehub.resources.event.models import Remove, Test
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
@ -536,3 +537,30 @@ def test_networking_model():
switch = d.Switch(speed=1000, wireless=False) switch = d.Switch(speed=1000, wireless=False)
db.session.add(switch) db.session.add(switch)
db.session.commit() 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'