test for recycling documents

This commit is contained in:
Cayo Puigdefabregas 2021-09-29 21:12:46 +02:00
parent 7e4af161d3
commit eeb6db7bc2
2 changed files with 24 additions and 0 deletions

View file

@ -426,6 +426,11 @@ class Ready(ActionWithMultipleDevices):
class ActionStatus(ActionWithMultipleDevices): class ActionStatus(ActionWithMultipleDevices):
rol_user = NestedOn(s_user.User, dump_only=True, exclude=('token',)) rol_user = NestedOn(s_user.User, dump_only=True, exclude=('token',))
documents = NestedOn(s_document.TradeDocument,
many=True,
required=False, # todo test ensuring len(devices) >= 1
only_query='id',
collection_class=OrderedSet)
@post_load @post_load
def put_rol_user(self, data: dict): def put_rol_user(self, data: dict):

View file

@ -470,6 +470,25 @@ def test_use_changing_owner(user: UserClient, user2: UserClient):
assert device.owner.email == user2.email assert device.owner.email == user2.email
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_recycling_container(user: UserClient):
lot, _ = user.post({'name': 'MyLotOut'}, res=Lot)
url = 'http://www.ereuse.org/',
request_post = {
'filename': 'test.pdf',
'hash': 'bbbbbbbb',
'url': url,
'weight': 150,
'lot': lot['id']
}
tradedocument, _ = user.post(res=TradeDocument, data=request_post)
action = {'type': models.Recycling.t, 'devices': [], 'documents': [tradedocument['id']]}
action, _ = user.post(action, res=models.Action)
trade = TradeDocument.query.one()
assert str(trade.actions[0].id) == action['id']
@pytest.mark.mvp @pytest.mark.mvp
def test_reuse(user: UserClient): def test_reuse(user: UserClient):
snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot) snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot)