Fix getting wrong lots from inventory

This commit is contained in:
Xavier Bustamante Talavera 2018-09-21 11:25:22 +02:00
parent bc95fa98b1
commit 863d3b5639
3 changed files with 11 additions and 4 deletions

View File

@ -68,8 +68,6 @@ class Dummy:
snapshot = yaml.load(f)
s, _ = user.post(res=m.Snapshot, data=snapshot)
pcs.add(s['device']['id'])
inventory, _ = user.get(res=Inventory)
assert len(inventory['devices'])
# Link tags and eTags
for tag, pc in zip((self.TAGS[1], self.TAGS[2], self.ET[0][0], self.ET[1][1]), pcs):
@ -99,6 +97,10 @@ class Dummy:
query=[('id', pc) for pc in itertools.islice(pcs, len(pcs) // 3)])
assert len(lot['devices'])
# Keep this at the bottom
inventory, _ = user.get(res=Inventory)
assert len(inventory['devices'])
assert len(inventory['lots'])
print('⭐ Done.')
def user_client(self, email: str, password: str):

View File

@ -98,7 +98,7 @@ class InventoryView(View):
.paginate(page=args['page'], per_page=30) # type: Pagination
inventory = {
'devices': app.resources[Device.t].schema.dump(devices.items, many=True, nested=1),
'lots': Lot.roots(),
'lots': app.resources[Lot.t].schema.dump(Lot.roots(), many=True, nested=1),
'widgets': {},
'pagination': {
'page': devices.page,

View File

@ -1,4 +1,5 @@
import pytest
from teal.utils import compiled
from ereuse_devicehub.client import UserClient
from ereuse_devicehub.db import db
@ -7,7 +8,6 @@ from ereuse_devicehub.resources.device.models import Desktop, Device, Laptop, So
from ereuse_devicehub.resources.enums import ComputerChassis
from ereuse_devicehub.resources.event.models import Snapshot
from ereuse_devicehub.resources.inventory import Filters, Inventory, Sorting
from teal.utils import compiled
from tests import conftest
@ -102,3 +102,8 @@ def test_inventory_query(user: UserClient):
assert len(pc['events']) == 4
assert len(pc['components']) == 3
assert not pc['tags']
@pytest.mark.xfail(reason='Functionality not yet developed.')
def test_inventory_lots_query(user: UserClient):
pass