From 1aaf0a9ae7edb0d6efc2746b69e6fb2be6662b43 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 3 Sep 2021 16:05:55 +0200 Subject: [PATCH] build tests for moveon --- tests/test_action.py | 46 +++++++++++++++++++++++++++++++++++++++++ tests/test_documents.py | 46 ++++++++++++++++++++--------------------- 2 files changed, 69 insertions(+), 23 deletions(-) diff --git a/tests/test_action.py b/tests/test_action.py index 03868c3c..7de78e3b 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -28,6 +28,7 @@ from ereuse_devicehub.resources.action import models from ereuse_devicehub.resources.device import states from ereuse_devicehub.resources.device.models import Desktop, Device, GraphicCard, HardDrive, \ RamModule, SolidStateDrive +from ereuse_devicehub.resources.tradedocument.models import TradeDocument from ereuse_devicehub.resources.enums import ComputerChassis, Severity, TestDataStorageLength from tests import conftest from tests.conftest import create_user, file, yaml2json, json_encode @@ -2438,3 +2439,48 @@ def test_action_web_erase(user: UserClient, client: Client): assert "alert alert-info" in response assert "100% coincidence." in response assert not "alert alert-danger" in response + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_moveonContainer(user: UserClient, user2: UserClient): + 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) + request_post2 = { + 'filename': 'test.pdf', + 'hash': 'bbbbbbbb', + '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) + + request_moveOn = { + 'weight': 15, + 'container_from': tradedocument_from['id'], + 'container_to': tradedocument_to['id'] + } + import pdb; pdb.set_trace() + doc, _ = user.post(res=models.Action, data=request_moveOn) diff --git a/tests/test_documents.py b/tests/test_documents.py index 9ed874b2..043ebaa5 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -718,27 +718,27 @@ def test_trade_documents_with_weight(user: UserClient): assert doc['weight'] == request_post['weight'] -@pytest.mark.mvp -@pytest.mark.usefixtures(conftest.app_context.__name__) -def test_recycle_document(user: UserClient): - """Tests upload one document""" +# @pytest.mark.mvp +# @pytest.mark.usefixtures(conftest.app_context.__name__) +# def test_recycle_document(user: UserClient): +# """Tests upload one document""" - lotIn, _ = user.post({'name': 'MyLotIn'}, res=Lot) - lotOut, _ = user.post({'name': 'MyLotOut'}, res=Lot) - url = 'http://www.ereuse.org/apapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapaaaa', - request_post = { - 'filename': 'test.pdf', - 'hash': 'bbbbbbbb', - 'url': url, - 'weight': 15, - 'lot': lotOut['id'] - } - tradedocument, _ = user.post(res=TradeDocument, data=request_post) - # import pdb; pdb.set_trace() - request_post2 = { - 'weight': 15, - 'hash': tradedocument['hash'], - 'lot': lotIn['id'] - } - doc, _ = user.post(res=documents.DocumentDef.t, item='recycle/', data=request_post2) - assert doc == request_post['filename'] +# lotIn, _ = user.post({'name': 'MyLotIn'}, res=Lot) +# lotOut, _ = user.post({'name': 'MyLotOut'}, res=Lot) +# url = 'http://www.ereuse.org/apapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapapaapaapaapaapaapaapaapaapaapaaaa', +# request_post = { +# 'filename': 'test.pdf', +# 'hash': 'bbbbbbbb', +# 'url': url, +# 'weight': 15, +# 'lot': lotOut['id'] +# } +# tradedocument, _ = user.post(res=TradeDocument, data=request_post) +# # import pdb; pdb.set_trace() +# request_post2 = { +# 'weight': 15, +# 'hash': tradedocument['hash'], +# 'lot': lotIn['id'] +# } +# doc, _ = user.post(res=documents.DocumentDef.t, item='recycle/', data=request_post2) +# assert doc == request_post['filename']