clean code test
This commit is contained in:
parent
d8382f8331
commit
aa17d4b492
|
@ -14,7 +14,6 @@ from ereuse_devicehub.resources import enums
|
||||||
from ereuse_devicehub.resources.device import models as m, states
|
from ereuse_devicehub.resources.device import models as m, states
|
||||||
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
|
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
|
||||||
from ereuse_devicehub.resources.schemas import Thing, UnitCodes
|
from ereuse_devicehub.resources.schemas import Thing, UnitCodes
|
||||||
# from ereuse_devicehub.resources.action.schemas import Action as s_action
|
|
||||||
|
|
||||||
|
|
||||||
class Device(Thing):
|
class Device(Thing):
|
||||||
|
@ -41,10 +40,13 @@ class Device(Thing):
|
||||||
width = Float(validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.width.comment)
|
width = Float(validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.width.comment)
|
||||||
height = Float(validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.height.comment)
|
height = Float(validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.height.comment)
|
||||||
depth = Float(validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.depth.comment)
|
depth = Float(validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.depth.comment)
|
||||||
|
# TODO TimeOut 2. Comment actions and lots if there are time out.
|
||||||
actions = NestedOn('Action', many=True, dump_only=True, description=m.Device.actions.__doc__)
|
actions = NestedOn('Action', many=True, dump_only=True, description=m.Device.actions.__doc__)
|
||||||
|
# TODO TimeOut 2. Comment actions_one and lots if there are time out.
|
||||||
actions_one = NestedOn('Action', many=True, load_only=True, collection_class=OrderedSet)
|
actions_one = NestedOn('Action', many=True, load_only=True, collection_class=OrderedSet)
|
||||||
problems = NestedOn('Action', many=True, dump_only=True, description=m.Device.problems.__doc__)
|
problems = NestedOn('Action', many=True, dump_only=True, description=m.Device.problems.__doc__)
|
||||||
url = URL(dump_only=True, description=m.Device.url.__doc__)
|
url = URL(dump_only=True, description=m.Device.url.__doc__)
|
||||||
|
# TODO TimeOut 2. Comment actions and lots if there are time out.
|
||||||
lots = NestedOn('Lot',
|
lots = NestedOn('Lot',
|
||||||
many=True,
|
many=True,
|
||||||
dump_only=True,
|
dump_only=True,
|
||||||
|
@ -97,79 +99,9 @@ class Device(Thing):
|
||||||
field_names=['actions'])
|
field_names=['actions'])
|
||||||
|
|
||||||
|
|
||||||
ACTIONS_VALUE = (
|
|
||||||
'id',
|
|
||||||
'type',
|
|
||||||
'created'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
TAGS_VALUE = (
|
|
||||||
'id',
|
|
||||||
'printable',
|
|
||||||
'code',
|
|
||||||
'device',
|
|
||||||
'type',
|
|
||||||
'url'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Device2(Thing):
|
|
||||||
__doc__ = m.Device.__doc__
|
|
||||||
id = Integer(description=m.Device.id.comment, dump_only=True)
|
|
||||||
hid = SanitizedStr(lower=True, description=m.Device.hid.comment)
|
|
||||||
tags = f.Nested('Tag',
|
|
||||||
many=True,
|
|
||||||
collection_class=OrderedSet,
|
|
||||||
description='A set of tags that identify the device.',
|
|
||||||
only=TAGS_VALUE)
|
|
||||||
model = SanitizedStr(lower=True,
|
|
||||||
validate=Length(max=STR_BIG_SIZE),
|
|
||||||
description=m.Device.model.comment)
|
|
||||||
manufacturer = SanitizedStr(lower=True,
|
|
||||||
validate=Length(max=STR_SIZE),
|
|
||||||
description=m.Device.manufacturer.comment)
|
|
||||||
serial_number = SanitizedStr(lower=True,
|
|
||||||
validate=Length(max=STR_BIG_SIZE),
|
|
||||||
data_key='serialNumber')
|
|
||||||
# actions = NestedOn('Action', many=True, dump_only=True, description=m.Device.actions.__doc__)
|
|
||||||
actions = f.Nested('Action', only=ACTIONS_VALUE, many=True)
|
|
||||||
# actions = f.Nested(s_actions.Action(only=ACTIONS_VALUE),
|
|
||||||
# many=True,
|
|
||||||
# dump_only=True,
|
|
||||||
# description=m.Device.actions.__doc__)
|
|
||||||
# actions_one = NestedOn('Action', many=True, load_only=True, collection_class=OrderedSet)
|
|
||||||
url = URL(dump_only=True, description=m.Device.url.__doc__)
|
|
||||||
# lots = NestedOn('Lot',
|
|
||||||
# many=True,
|
|
||||||
# dump_only=True,
|
|
||||||
# description='The lots where this device is directly under.')
|
|
||||||
tradings = Dict(dump_only=True, description='')
|
|
||||||
traking = EnumField(states.Traking, dump_only=True, description=m.Device.physical.__doc__)
|
|
||||||
revoke = UUID(dump_only=True)
|
|
||||||
allocated = Boolean(description=m.Device.allocated.comment)
|
|
||||||
devicehub_id = SanitizedStr(data_key='devicehubID',
|
|
||||||
description=m.Device.devicehub_id.comment)
|
|
||||||
|
|
||||||
|
|
||||||
COMPONENTS_VALUES = (
|
|
||||||
'type',
|
|
||||||
'manufacturer',
|
|
||||||
'model'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Computer2(Device):
|
|
||||||
__doc__ = m.Computer.__doc__
|
|
||||||
# components = f.Nested(Component(only=COMPONENTS_VALUES),
|
|
||||||
# many=True,
|
|
||||||
# dump_only=True,
|
|
||||||
# collection_class=OrderedSet,
|
|
||||||
# description='The components that are inside this computer.')
|
|
||||||
|
|
||||||
|
|
||||||
class Computer(Device):
|
class Computer(Device):
|
||||||
__doc__ = m.Computer.__doc__
|
__doc__ = m.Computer.__doc__
|
||||||
|
# TODO TimeOut 1. Comment components if there are time out.
|
||||||
components = NestedOn('Component',
|
components = NestedOn('Component',
|
||||||
many=True,
|
many=True,
|
||||||
dump_only=True,
|
dump_only=True,
|
||||||
|
|
Reference in New Issue