diff --git a/ereuse_devicehub/resources/action/__init__.py b/ereuse_devicehub/resources/action/__init__.py index 01b32ac4..1cf8c1b7 100644 --- a/ereuse_devicehub/resources/action/__init__.py +++ b/ereuse_devicehub/resources/action/__init__.py @@ -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 diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 54f30324..907b61e0 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -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): diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index e6eb6b4f..cd86a671 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -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, diff --git a/ereuse_devicehub/resources/device/states.py b/ereuse_devicehub/resources/device/states.py index a67a410d..4d03778a 100644 --- a/ereuse_devicehub/resources/device/states.py +++ b/ereuse_devicehub/resources/device/states.py @@ -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 diff --git a/tests/test_action.py b/tests/test_action.py index ba095685..f5d00280 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -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 diff --git a/tests/test_basic.py b/tests/test_basic.py index fe3dd1da..065ba42c 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -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