fixing tests

This commit is contained in:
Cayo Puigdefabregas 2020-11-23 11:43:30 +01:00
parent ee70288432
commit 73716a7331
6 changed files with 20 additions and 7 deletions

View File

@ -228,6 +228,11 @@ class DonateDef(ActionDef):
SCHEMA = schemas.Donate
class RentDef(ActionDef):
VIEW = None
SCHEMA = schemas.Rent
class MakeAvailable(ActionDef):
VIEW = None
SCHEMA = schemas.MakeAvailable

View File

@ -257,10 +257,12 @@ class Device(Thing):
and :class:`ereuse_devicehub.resources.action.models.Receive`
changes it.
"""
from ereuse_devicehub.resources.action.models import Receive
with suppress(LookupError):
action = self.last_action_of(Receive)
return action.agent_to
pass
# TODO @cayop uncomment this lines for link the possessor with the device
# from ereuse_devicehub.resources.action.models import Receive
# with suppress(LookupError):
# action = self.last_action_of(Receive)
# return action.agent_to
@property
def working(self):

View File

@ -52,6 +52,8 @@ class Device(Thing):
price = NestedOn('Price', dump_only=True, description=m.Device.price.__doc__)
trading = EnumField(states.Trading, dump_only=True, description=m.Device.trading.__doc__)
physical = EnumField(states.Physical, dump_only=True, description=m.Device.physical.__doc__)
traking= EnumField(states.Traking, dump_only=True, description=m.Device.physical.__doc__)
usage = EnumField(states.Usage, dump_only=True, description=m.Device.physical.__doc__)
physical_possessor = NestedOn('Agent', dump_only=True, data_key='physicalPossessor')
production_date = DateTime('iso',
description=m.Device.updated.comment,

View File

@ -72,7 +72,9 @@ class Usage(State):
"""Usage states.
:cvar Allocate: The device is allocate in other Agent (organization, person ...)
:cvar Deallocate: The device is deallocate and return to the owner
:cvar InUse: The device is being reported to be in active use.
"""
Allocate = e.Allocate
Deallocate = e.Deallocate
InUse = e.Live

View File

@ -265,7 +265,7 @@ def test_live():
assert live['subdivision'] == 'ES-CA'
assert live['country'] == 'ES'
device, _ = client.get(res=Device, item=live['device']['id'])
assert device['physical'] == states.Physical.InUse.name
assert device['usage'] == states.Usage.InUse.name
@pytest.mark.mvp

View File

@ -100,7 +100,9 @@ def test_api_docs(client: Client):
'/videoconferences/{id}/merge/',
'/videos/{id}/merge/',
'/wireless-access-points/{id}/merge/',
'/versions/'
'/versions/',
'/allocates/',
'/deallocates/',
}
assert docs['info'] == {'title': 'Devicehub', 'version': '0.2'}
assert docs['components']['securitySchemes']['bearerAuth'] == {
@ -111,4 +113,4 @@ def test_api_docs(client: Client):
'scheme': 'basic',
'name': 'Authorization'
}
assert len(docs['definitions']) == 122
assert len(docs['definitions']) == 123