From 74af5add3c20173ee70eb387a432bbed276e184f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 6 Sep 2021 12:45:47 +0200 Subject: [PATCH] adding action moveOn endpoint --- ereuse_devicehub/resources/action/__init__.py | 5 +++++ ereuse_devicehub/resources/action/schemas.py | 7 +++++++ tests/test_action.py | 7 ++++++- tests/test_basic.py | 3 +-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/resources/action/__init__.py b/ereuse_devicehub/resources/action/__init__.py index bdc55014..f33fa0df 100644 --- a/ereuse_devicehub/resources/action/__init__.py +++ b/ereuse_devicehub/resources/action/__init__.py @@ -313,3 +313,8 @@ class MigrateToDef(ActionDef): class MigrateFromDef(ActionDef): VIEW = None SCHEMA = schemas.MigrateFrom + + +class MoveOnContainerDef(ActionDef): + VIEW = None + SCHEMA = schemas.MoveOnContainer diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 3232f11b..efe4df74 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -840,3 +840,10 @@ class MigrateTo(Migrate): class MigrateFrom(Migrate): __doc__ = m.MigrateFrom.__doc__ + + +class MoveOnContainer(Migrate): + __doc__ = m.MoveOnContainer.__doc__ + weight = Integer() + container_from = NestedOn('TradeDocument', only_query='id') + container_to = NestedOn('TradeDocument', only_query='id') diff --git a/tests/test_action.py b/tests/test_action.py index 7de78e3b..345e7101 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -2478,9 +2478,14 @@ def test_moveonContainer(user: UserClient, user2: UserClient): user.post(res=models.Action, data=request_trade) request_moveOn = { + 'type': 'MoveOnContainer', 'weight': 15, + 'devices': [], 'container_from': tradedocument_from['id'], 'container_to': tradedocument_to['id'] } - import pdb; pdb.set_trace() doc, _ = user.post(res=models.Action, data=request_moveOn) + + assert doc['weight'] == request_moveOn['weight'] + assert doc['container_from']['id'] == tradedocument_from['id'] + assert doc['container_to']['id'] == tradedocument_to['id'] diff --git a/tests/test_basic.py b/tests/test_basic.py index ac7537a8..c3dc44d3 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -43,7 +43,6 @@ def test_api_docs(client: Client): '/documents/wbconf/{wbtype}', '/documents/internalstats/', '/documents/stock/', - '/documents/recycle/', '/documents/check/', '/documents/lots/', '/versions/', @@ -123,4 +122,4 @@ def test_api_docs(client: Client): 'scheme': 'basic', 'name': 'Authorization' } - assert len(docs['definitions']) == 126 + assert len(docs['definitions']) == 127