From b83bbe25a0212fbe2198bb0324e8467e4bc45706 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 1 Oct 2021 18:01:39 +0200 Subject: [PATCH] test bug 168 --- tests/test_action.py | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/test_action.py b/tests/test_action.py index fe94d518..a1363d84 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -2521,3 +2521,59 @@ def test_moveOnDocument(user: UserClient, user2: UserClient): assert description == mvs.description tradedocument_to, _ = user.post(res=TradeDocument, data=request_post2) user.post(res=models.Action, data=request_moveOn, status=422) + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_moveOnDocument_bug168(user: UserClient, user2: UserClient): + """If you use one moveOnDocument in a trade Document. Next you can not drop this document.""" + lotIn, _ = user.post({'name': 'MyLotIn'}, res=Lot) + lotOut, _ = user.post({'name': 'MyLotOut'}, res=Lot) + url = 'http://www.ereuse.org/apapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapaaaa', + request_post1 = { + 'filename': 'test.pdf', + 'hash': 'bbbbbbbb', + 'url': url, + 'weight': 150, + 'lot': lotIn['id'] + } + tradedocument_from, _ = user.post(res=TradeDocument, data=request_post1) + id_hash = 'aaaaaaaaa' + request_post2 = { + 'filename': 'test.pdf', + 'hash': id_hash, + 'url': url, + 'weight': 0, + 'lot': lotOut['id'] + } + tradedocument_to, _ = user.post(res=TradeDocument, data=request_post2) + + request_trade = { + 'type': 'Trade', + 'devices': [], + 'userFromEmail': user2.email, + 'userToEmail': user.email, + 'price': 10, + 'date': "2020-12-01T02:00:00+00:00", + 'lot': lotIn['id'], + 'confirms': True, + } + + user.post(res=models.Action, data=request_trade) + + description = 'This is a good description' + request_moveOn = { + 'type': 'MoveOnDocument', + 'weight': 15, + 'container_from': tradedocument_from['id'], + 'container_to': id_hash, + 'description': description + } + 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'] + + import pdb; pdb.set_trace() + tradedocument, _ = user.delete(res=TradeDocument, item=tradedocument_to['id'])