From e861ae3bf8f0ba14c09a4640504ecfcee9ac8ffb Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 22 Sep 2021 14:33:46 +0200 Subject: [PATCH] adding tests for recycling and reuse --- tests/test_action.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_action.py b/tests/test_action.py index 03868c3c..dc5bb7bb 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -255,6 +255,24 @@ def test_generic_action(action_model_state: Tuple[models.Action, states.Trading] assert snapshot['device']['updated'] != device['updated'] +@pytest.mark.mvp +def test_recycling(user: UserClient): + snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot) + action = {'type': models.Recycling.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 +def test_reuse(user: UserClient): + snap, _ = user.post(file('basic.snapshot'), res=models.Snapshot) + action = {'type': models.Reuse.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.usefixtures(conftest.app_context.__name__) def test_live(user: UserClient, client: Client, app: Devicehub):