From fdea06f08f55682d8b484065b1823541caa6e290 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 17 Aug 2021 11:22:50 +0200 Subject: [PATCH] specific test for unassign --- tests/test_device.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_device.py b/tests/test_device.py index 6ee5f9f8..9dcfd53f 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -512,6 +512,33 @@ def test_get_devices_unassigned(app: Devicehub, user: UserClient): assert res.status_code == 200 assert len(devices['items']) == 1 + url = '/devices/?filter={"type":["Computer"]}&unassign=1' + + devices, res = user.get(url, None) + assert res.status_code == 200 + assert len(devices['items']) == 1 + + from ereuse_devicehub.resources.lot.models import Lot + device_id = devices['items'][0]['id'] + my_lot, _ = user.post(({'name': 'My_lot'}), res=Lot) + lot, _ = user.post({}, + res=Lot, + item='{}/devices'.format(my_lot['id']), + query=[('id', device_id)]) + assert lot['devices'][0]['id'] == device_id, 'Lot contains device' + + url = '/devices/?filter={"type":["Computer"]}&unassign=0' + + devices, res = user.get(url, None) + assert res.status_code == 200 + assert len(devices['items']) == 1 + + url = '/devices/?filter={"type":["Computer"]}&unassign=1' + + devices, res = user.get(url, None) + assert res.status_code == 200 + assert len(devices['items']) == 0 + @pytest.mark.mvp @pytest.mark.usefixtures(conftest.auth_app_context.__name__)