fixing minor changes of review

This commit is contained in:
Cayo Puigdefabregas 2021-10-18 11:20:05 +02:00
parent cae0ca8711
commit 2d37baca8d
2 changed files with 37 additions and 4 deletions

View File

@ -1351,7 +1351,6 @@ class DataWipe(JoinedTableMixin, ActionWithMultipleDevices):
class ActionStatus(JoinedTableMixin, ActionWithMultipleTradeDocuments): class ActionStatus(JoinedTableMixin, ActionWithMultipleTradeDocuments):
# class ActionStatus(JoinedTableMixin, ActionWithMultipleDevices):
"""This is a meta-action than mark the status of the devices""" """This is a meta-action than mark the status of the devices"""
rol_user_id = db.Column(UUID(as_uuid=True), rol_user_id = db.Column(UUID(as_uuid=True),
@ -1500,7 +1499,7 @@ class CancelReservation(Organize):
class ActionStatusDocuments(JoinedTableMixin, ActionWithMultipleTradeDocuments): class ActionStatusDocuments(JoinedTableMixin, ActionWithMultipleTradeDocuments):
"""This is a meta-action than mark the status of the devices""" """This is a meta-action that marks the state of the devices."""
rol_user_id = db.Column(UUID(as_uuid=True), rol_user_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(User.id), db.ForeignKey(User.id),
nullable=False, nullable=False,

View File

@ -473,6 +473,7 @@ def test_use_changing_owner(user: UserClient, user2: UserClient):
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__) @pytest.mark.usefixtures(conftest.app_context.__name__)
def test_recycling_container(user: UserClient): def test_recycling_container(user: UserClient):
"""Test of status action recycling for a container."""
lot, _ = user.post({'name': 'MyLotOut'}, res=Lot) lot, _ = user.post({'name': 'MyLotOut'}, res=Lot)
url = 'http://www.ereuse.org/', url = 'http://www.ereuse.org/',
request_post = { request_post = {
@ -490,9 +491,42 @@ def test_recycling_container(user: UserClient):
@pytest.mark.mvp @pytest.mark.mvp
def test_reuse(user: UserClient): @pytest.mark.parametrize('action_model',
(pytest.param(ams, id=ams.__class__.__name__)
for ams in [
models.Recycling,
models.Use,
models.Refurbish,
models.Management
]))
def test_status_without_lot(action_model: models.Action, user: UserClient):
"""Test of status actions for devices without lot."""
snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot) snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot)
action = {'type': models.Use.t, 'devices': [snap['device']['id']]} action = {'type': action_model.t, 'devices': [snap['device']['id']]}
action, _ = user.post(action, res=models.Action)
device, _ = user.get(res=Device, item=snap['device']['devicehubID'])
assert device['actions'][-1]['id'] == action['id']
@pytest.mark.mvp
@pytest.mark.parametrize('action_model',
(pytest.param(ams, id=ams.__class__.__name__)
for ams in [
models.Recycling,
models.Use,
models.Refurbish,
models.Management
]))
def test_status_in_temporary_lot(action_model: models.Action, user: UserClient):
"""Test of status actions for devices in a temporary lot."""
snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot)
device_id = snap['device']['id']
lot, _ = user.post({'name': 'MyLotOut'}, res=Lot)
lot, _ = user.post({},
res=Lot,
item='{}/devices'.format(lot['id']),
query=[('id', device_id)])
action = {'type': action_model.t, 'devices': [device_id]}
action, _ = user.post(action, res=models.Action) action, _ = user.post(action, res=models.Action)
device, _ = user.get(res=Device, item=snap['device']['devicehubID']) device, _ = user.get(res=Device, item=snap['device']['devicehubID'])
assert device['actions'][-1]['id'] == action['id'] assert device['actions'][-1]['id'] == action['id']