Merge branch 'testing' into feature/new-metrix

This commit is contained in:
Cayo Puigdefabregas 2021-10-18 11:53:05 +02:00
commit 31de27769d
3 changed files with 37 additions and 5 deletions

View File

@ -10,7 +10,6 @@ ml).
## testing
[1.0.10-beta]
- [addend] #166 new action recycling and reuse
## [1.0.10-beta]
- [bugfix] #168 can to do a trade without devices.

View File

@ -1352,7 +1352,6 @@ class DataWipe(JoinedTableMixin, ActionWithMultipleDevices):
class ActionStatus(JoinedTableMixin, ActionWithMultipleTradeDocuments):
# class ActionStatus(JoinedTableMixin, ActionWithMultipleDevices):
"""This is a meta-action than mark the status of the devices"""
rol_user_id = db.Column(UUID(as_uuid=True),
@ -1501,7 +1500,7 @@ class CancelReservation(Organize):
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),
db.ForeignKey(User.id),
nullable=False,

View File

@ -473,6 +473,7 @@ def test_use_changing_owner(user: UserClient, user2: UserClient):
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_recycling_container(user: UserClient):
"""Test of status action recycling for a container."""
lot, _ = user.post({'name': 'MyLotOut'}, res=Lot)
url = 'http://www.ereuse.org/',
request_post = {
@ -490,9 +491,42 @@ def test_recycling_container(user: UserClient):
@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)
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)
device, _ = user.get(res=Device, item=snap['device']['devicehubID'])
assert device['actions'][-1]['id'] == action['id']