From aaafb2a5fa993104bd8a2b480d27717a16b848eb Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 19 Apr 2021 21:31:22 +0200 Subject: [PATCH] test about trade notes --- tests/test_action.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/test_action.py b/tests/test_action.py index 3eaab94c..b75e1a9a 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -800,7 +800,7 @@ def test_offer_without_to(user: UserClient): } user.post(res=models.Action, data=request_post) - trade= models.Trade.query.one() + trade = models.Trade.query.one() assert device in trade.devices # assert trade.confirm_transfer users = [ac.user for ac in trade.acceptances] @@ -827,6 +827,7 @@ def test_offer_without_to(user: UserClient): 'code': 'MAX' } user.post(res=models.Action, data=request_post, status=422) + trade = models.Trade.query.one() # Check if the new phantom account is reused and not duplicated computer = file('1-device-with-components.snapshot') @@ -960,6 +961,7 @@ def test_offer(user: UserClient): assert device.owner.email == user.email assert device.owner.email != user2.email + @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_offer_without_devices(user: UserClient): @@ -984,6 +986,38 @@ def test_offer_without_devices(user: UserClient): user.post(res=models.Action, data=request_post) # no there are transfer of devices + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_automatic_note_to_trade(user: UserClient, user2: UserClient): + """Check than there are one note when one device is insert in one trade lot""" + lot, _ = user.post({'name': 'MyLot'}, res=Lot) + request_post = { + 'type': 'Trade', + 'devices': [], + 'userFrom': user.email, + 'userTo': user2.email, + 'price': 10, + 'date': "2020-12-01T02:00:00+00:00", + 'documentID': '1', + 'lot': lot['id'], + 'confirm': True, + } + + user.post(res=models.Action, data=request_post) + trade = models.Trade.query.one() + assert trade.notes == [] + + snapshot, _ = user.post(file('basic.snapshot'), res=models.Snapshot) + device = Device.query.filter_by(id=snapshot['device']['id']).one() + lot, _ = user.post({}, + res=Lot, + item='{}/devices'.format(lot['id']), + query=[('id', device.id)]) + assert len(trade.notes) == 1 + assert trade.notes[0].device_id == device.id + + @pytest.mark.mvp @pytest.mark.usefixtures(conftest.auth_app_context.__name__) def test_price_custom():