Creating new test for device stock control

This commit is contained in:
nad 2020-07-27 13:57:31 +02:00
parent c90fa4e84e
commit 322af04ff9
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Type ,Chassis ,Serial Number,Model,Manufacturer,Registered in ,Physical state,Trading state,Price,Processor,RAM (MB),Data Storage Size (MB),Rate,Range ,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range
Desktop,Microtower,d1s ,d1ml ,d1mr ,Tue Jul 2 10:35:10 2019, , , ,p1ml ,0 ,0 ,1.0 ,Very low,1.0 ,Very low ,1.0 ,Very low ,1.0 ,Very low
1 Type Chassis Serial Number Model Manufacturer Registered in Physical state Trading state Price Processor RAM (MB) Data Storage Size (MB) Rate Range Processor Rate Processor Range RAM Rate RAM Range Data Storage Rate Data Storage Range
2 Desktop Microtower d1s d1ml d1mr Tue Jul 2 10:35:10 2019 p1ml 0 0 1.0 Very low 1.0 Very low 1.0 Very low 1.0 Very low

View file

@ -223,3 +223,31 @@ def test_export_multiple_different_devices(user: UserClient):
del row[8]
assert fixture_csv == export_csv
@pytest.mark.mvp
def test_report_devices_stock_control(user: UserClient):
"""Test export device information in a csv file."""
snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot)
csv_str, _ = user.get(res=documents.DocumentDef.t,
item='stock/',
accept='text/csv',
query=[('filter', {'type': ['Computer']})])
f = StringIO(csv_str)
obj_csv = csv.reader(f, f)
export_csv = list(obj_csv)
# Open fixture csv and transform to list
with Path(__file__).parent.joinpath('files').joinpath('basic-stock.csv').open() as csv_file:
obj_csv = csv.reader(csv_file)
fixture_csv = list(obj_csv)
assert isinstance(datetime.strptime(export_csv[1][5], '%c'), datetime), \
'Register in field is not a datetime'
# Pop dates fields from csv lists to compare them
fixture_csv[1] = fixture_csv[1][:5] + fixture_csv[1][6:]
export_csv[1] = export_csv[1][:5] + export_csv[1][6:]
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1] == export_csv[1], 'Computer information are not equal'