Minors comments changes and new test_get_all_lots was added

This commit is contained in:
nad 2020-07-28 16:22:17 +02:00
parent c0fcfcfdbf
commit a2303498cd
2 changed files with 16 additions and 2 deletions

View File

@ -134,7 +134,7 @@ class LotsDocumentView(LotView):
return self.generate_lots_csv(Lot.query) return self.generate_lots_csv(Lot.query)
def generate_lots_csv(self, query): def generate_lots_csv(self, query):
"""Get device query and put information in csv format.""" """Get lot query and put information in csv format."""
data = StringIO() data = StringIO()
cw = csv.writer(data) cw = csv.writer(data)
first = True first = True
@ -154,7 +154,7 @@ class LotRow(OrderedDict):
def __init__(self, lot: Lot) -> None: def __init__(self, lot: Lot) -> None:
super().__init__() super().__init__()
self.lot = lot self.lot = lot
# General information about device # General information about lot
self['Id'] = lot.id.hex self['Id'] = lot.id.hex
self['Name'] = lot.name self['Name'] = lot.name
self['Registered in'] = format(lot.created, '%c') self['Registered in'] = format(lot.created, '%c')

View File

@ -381,3 +381,17 @@ def test_lot_post_add_remove_device_view(app: Devicehub, user: UserClient):
query=[('id', device_id)], query=[('id', device_id)],
status=200) status=200)
assert not len(lot['devices']) assert not len(lot['devices'])
@pytest.mark.mvp
def test_get_all_lots(user: UserClient):
"""Tests submitting and retreiving all lots."""
l, _ = user.post({'name': 'Lot1', 'description': 'comments,lot1,testcomment,'}, res=Lot)
l, _ = user.post({'name': 'Lot2', 'description': 'comments,lot2,testcomment,'}, res=Lot)
l, _ = user.post({'name': 'Lot3', 'description': 'comments3,lot3,testcomment,'}, res=Lot)
l, _ = user.get(res=Lot)
assert l['items'][0]['name'] == 'Lot1'
assert l['items'][0]['description'] == 'comments,lot1,testcomment,'
assert l['items'][2]['name'] == 'Lot3'
assert l['items'][2]['description'] == 'comments,lot3,testcomment,'