Merge remote-tracking branch 'origin/rate' into rate

This commit is contained in:
Xavier Bustamante Talavera 2019-06-12 16:50:08 +02:00
commit b0d8ca39fe
4 changed files with 23 additions and 51 deletions

View File

@ -1,17 +1,5 @@
Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price,Processor,RAM (GB),Data Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,DataStorage 1,DataStorage 1 Manufacturer,DataStorage 1 Model,DataStorage 1 Serial Number,DataStorage 2,DataStorage 2 Manufacturer,DataStorage 2 Model,DataStorage 2 Serial Number,DataStorage 3,DataStorage 3 Manufacturer,DataStorage 3 Model,DataStorage 3 Serial Number,DataStorage 4,DataStorage 4 Manufacturer,DataStorage 4 Model,DataStorage 4 Serial Number,Display 1,Display 1 Manufacturer,Display 1 Model,Display 1 Serial Number,GraphicCard 1,GraphicCard 1 Manufacturer,GraphicCard 1 Model,GraphicCard 1 Serial Number,GraphicCard 1 Memory (MB),GraphicCard 2,GraphicCard 2 Manufacturer,GraphicCard 2 Model,GraphicCard 2 Serial Number,Motherboard 1,Motherboard 1 Manufacturer,Motherboard 1 Model,Motherboard 1 Serial Number,NetworkAdapter 1,NetworkAdapter 1 Manufacturer,NetworkAdapter 1 Model,NetworkAdapter 1 Serial Number,NetworkAdapter 2,NetworkAdapter 2 Manufacturer,NetworkAdapter 2 Model,NetworkAdapter 2 Serial Number,Processor 1,Processor 1 Manufacturer,Processor 1 Model,Processor 1 Serial Number,Processor 1 Number of cores,Processor 1 Speed (GHz),Processor 2,Processor 2 Manufacturer,Processor 2 Model,Processor 2 Serial Number,RamModule 1,RamModule 1 Manufacturer,RamModule 1 Model,RamModule 1 Serial Number,RamModule 1 Size (MB),RamModule 1 Speed (MHz),RamModule 2,RamModule 2 Manufacturer,RamModule 2 Model,RamModule 2 Serial Number,RamModule 3,RamModule 3 Manufacturer,RamModule 3 Model,RamModule 3 Serial Number,RamModule 4,RamModule 4 Manufacturer,RamModule 4 Model,RamModule 4 Serial Number,SoundCard 1,SoundCard 1 Manufacturer,SoundCard 1 Model,SoundCard 1 Serial Number,SoundCard 2,SoundCard 2 Manufacturer,SoundCard 2 Model,SoundCard 2 Serial Number Type,Chassis,Tag 1,Tag 2,Tag 3,Serial Number,Model,Manufacturer,Registered in,Price,Processor,RAM (GB),Data Storage Size (MB),Rate,Range,Processor Rate,Processor Range,RAM Rate,RAM Range,Data Storage Rate,Data Storage Range,DataStorage 1,DataStorage 1 Manufacturer,DataStorage 1 Model,DataStorage 1 Serial Number,DataStorage 2,DataStorage 2 Manufacturer,DataStorage 2 Model,DataStorage 2 Serial Number,DataStorage 3,DataStorage 3 Manufacturer,DataStorage 3 Model,DataStorage 3 Serial Number,DataStorage 4,DataStorage 4 Manufacturer,DataStorage 4 Model,DataStorage 4 Serial Number,Display 1,Display 1 Manufacturer,Display 1 Model,Display 1 Serial Number,GraphicCard 1,GraphicCard 1 Manufacturer,GraphicCard 1 Model,GraphicCard 1 Serial Number,GraphicCard 1 Memory (MB),GraphicCard 2,GraphicCard 2 Manufacturer,GraphicCard 2 Model,GraphicCard 2 Serial Number,Motherboard 1,Motherboard 1 Manufacturer,Motherboard 1 Model,Motherboard 1 Serial Number,NetworkAdapter 1,NetworkAdapter 1 Manufacturer,NetworkAdapter 1 Model,NetworkAdapter 1 Serial Number,NetworkAdapter 2,NetworkAdapter 2 Manufacturer,NetworkAdapter 2 Model,NetworkAdapter 2 Serial Number,Processor 1,Processor 1 Manufacturer,Processor 1 Model,Processor 1 Serial Number,Processor 1 Number of cores,Processor 1 Speed (GHz),Processor 2,Processor 2 Manufacturer,Processor 2 Model,Processor 2 Serial Number,RamModule 1,RamModule 1 Manufacturer,RamModule 1 Model,RamModule 1 Serial Number,RamModule 1 Size (MB),RamModule 1 Speed (MHz),RamModule 2,RamModule 2 Manufacturer,RamModule 2 Model,RamModule 2 Serial Number,RamModule 3,RamModule 3 Manufacturer,RamModule 3 Model,RamModule 3 Serial Number,RamModule 4,RamModule 4 Manufacturer,RamModule 4 Model,RamModule 4 Serial Number,SoundCard 1,SoundCard 1 Manufacturer,SoundCard 1 Model,SoundCard 1 Serial Number,SoundCard 2,SoundCard 2 Manufacturer,SoundCard 2 Model,SoundCard 2 Serial Number
Laptop,Netbook,,,,b8oaas048286,1001pxd,asustek computer inc.,Wed Mar 6 18:22:05 2019,,intel atom cpu n455 @ 1.66ghz,1024,238475,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium,,,,,,,,,,,,,,,,,,,,,"GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None",,,,256,,,,,"Motherboard 10: model 1001pxd, S/N eee0123456789",eee0123456789,eee0123456789,eee0123456789,"NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8",74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,"NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c",14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,"Processor 4: model intel atom cpu n455 @ 1.66ghz, S/N None",,,,1,1.667,,,,,"RamModule 8: model None, S/N None",,,,1024,667,,,,,,,,,,,,,"SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None",,,,"SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001",0x0001,0x0001,0x0001 Laptop,Netbook,,,,b8oaas048286,1001pxd,asustek computer inc.,Wed Mar 6 18:22:05 2019,,intel atom cpu n455 @ 1.66ghz,1024,238475,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium,,,,,,,,,,,,,,,,,,,,,"GraphicCard 5: model atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller, S/N None",,,,256,,,,,"Motherboard 10: model 1001pxd, S/N eee0123456789",eee0123456789,eee0123456789,eee0123456789,"NetworkAdapter 2: model ar9285 wireless network adapter, S/N 74:2f:68:8b:fd:c8",74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,74:2f:68:8b:fd:c8,"NetworkAdapter 3: model ar8152 v2.0 fast ethernet, S/N 14:da:e9:42:f6:7c",14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,14:da:e9:42:f6:7c,"Processor 4: model intel atom cpu n455 @ 1.66ghz, S/N None",,,,1,1.667,,,,,"RamModule 8: model None, S/N None",,,,1024,667,,,,,,,,,,,,,"SoundCard 6: model nm10/ich7 family high definition audio controller, S/N None",,,,"SoundCard 7: model usb 2.0 uvc vga webcam, S/N 0x0001",0x0001,0x0001,0x0001
NetworkAdapter,,,,,74:2f:68:8b:fd:c8,ar9285 wireless network adapter,qualcomm atheros,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
NetworkAdapter,,,,,14:da:e9:42:f6:7c,ar8152 v2.0 fast ethernet,qualcomm atheros,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
Processor,,,,,,intel atom cpu n455 @ 1.66ghz,intel corp.,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
GraphicCard,,,,,,atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller,intel corporation,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
SoundCard,,,,,,nm10/ich7 family high definition audio controller,intel corporation,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
SoundCard,,,,,0x0001,usb 2.0 uvc vga webcam,azurewave,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
RamModule,,,,,,,,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
HardDrive,,,,,e2024242cv86hj,hts54322,hitachi,Wed Mar6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
Motherboard,,,,,eee0123456789,1001pxd,asustek computer inc.,Wed Mar 6 18:22:05 2019,,1.98,Very low,1.31,Very low,1.53,Very low,3.76,Medium
Desktop,Microtower,,,,d1s,d1ml,d1mr,Wed Mar 6 18:22:06 2019,,p1ml,0,0,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low,,,,,,,,,,,,,,,,,,,,,"GraphicCard 12: model gc1ml, S/N gc1s",gc1s,gc1s,gc1s,,,,,,,,,,,,,,,,,,"Processor 14: model p1ml, S/N p1s",p1s,p1s,p1s,,1.6,,,,,"RamModule 13: model rm1ml, S/N rm1s",rm1s,rm1s,rm1s,,1333,,,,,,,,,,,,,,,,,,,, Desktop,Microtower,,,,d1s,d1ml,d1mr,Wed Mar 6 18:22:06 2019,,p1ml,0,0,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low,,,,,,,,,,,,,,,,,,,,,"GraphicCard 12: model gc1ml, S/N gc1s",gc1s,gc1s,gc1s,,,,,,,,,,,,,,,,,,"Processor 14: model p1ml, S/N p1s",p1s,p1s,p1s,,1.6,,,,,"RamModule 13: model rm1ml, S/N rm1s",rm1s,rm1s,rm1s,,1333,,,,,,,,,,,,,,,,,,,,
GraphicCard,,,,,gc1s,gc1ml,gc1mr,Wed Mar 6 18:22:06 2019,,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
RamModule,,,,,rm1s,rm1ml,rm1mr,Wed Mar 6 18:22:06 2019,,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
Processor,,,,,p1s,p1ml,p1mr,Wed Mar 6 18:22:06 2019,,0.8,Very low,1.0,Very low,1.0,Very low,1.0,Very low
Keyboard,,,,,bar,foo,baz,Wed Mar 6 18:22:06 2019, Keyboard,,,,,bar,foo,baz,Wed Mar 6 18:22:06 2019,
ComputerMonitor,,,,,cn0fp446728728541c8s,1707fpf,dell,Wed Mar 6 18:22:06 2019, ComputerMonitor,,,,,cn0fp446728728541c8s,1707fpf,dell,Wed Mar 6 18:22:06 2019,

Can't render this file because it has a wrong number of fields in line 3.

View File

@ -28,7 +28,8 @@ def test_workbench_rate_db():
db.session.commit() db.session.commit()
# TODO JN is necessary this test if in test multiples rates we are checking same case?? @pytest.mark.xfail(reason='Rate algorithm v1 have the limitation of not '
'recompute rate when post new visual test')
def test_rate_with_multiple_visual_tests(user: UserClient): def test_rate_with_multiple_visual_tests(user: UserClient):
"""Perform a ComputerRate and then update the device with a new VisualTest. """Perform a ComputerRate and then update the device with a new VisualTest.
@ -160,7 +161,6 @@ def test_multiple_rates(user: UserClient):
rate1, price1 = RateComputer.compute(pc) rate1, price1 = RateComputer.compute(pc)
# asserts rate1 ... # asserts rate1 ...
# TODO JN is also necessary add asserts for component_range??
assert rate1.data_storage == 4.02 assert rate1.data_storage == 4.02
assert rate1.processor == 3.95 assert rate1.processor == 3.95
assert rate1.ram == 3.8 assert rate1.ram == 3.8
@ -169,18 +169,14 @@ def test_multiple_rates(user: UserClient):
assert rate1.functionality == 0.4 assert rate1.functionality == 0.4
assert rate1.rating == 4.62 assert rate1.rating == 4.62
# assert rate1.rating_range == 'High'
# TODO JN better option to get and assert price??
assert price1.price == Decimal('92.4001') assert price1.price == Decimal('92.4001')
assert math.isclose(rate1.price.price, 92.40, rel_tol=0.001)
hdd = SolidStateDrive(size=476940) hdd = SolidStateDrive(size=476940)
hdd.actions_one.add(BenchmarkDataStorage(read_speed=222, write_speed=169)) hdd.actions_one.add(BenchmarkDataStorage(read_speed=222, write_speed=169))
cpu = Processor(cores=1, speed=3.0) cpu = Processor(cores=1, speed=3.0)
cpu.actions_one.add(BenchmarkProcessor(rate=16069.44)) cpu.actions_one.add(BenchmarkProcessor(rate=16069.44))
# TODO JN best form to update pc components/benchmarks?? pc.components |= {
pc.components = {
hdd, hdd,
RamModule(size=2048, speed=1067), RamModule(size=2048, speed=1067),
RamModule(size=2048, speed=1067), RamModule(size=2048, speed=1067),
@ -192,12 +188,8 @@ def test_multiple_rates(user: UserClient):
functionality_range=FunctionalityRange.B, functionality_range=FunctionalityRange.B,
device=pc) device=pc)
# asserts pc characteristics/benchmarks/tests change
rate2, price2 = RateComputer.compute(pc) rate2, price2 = RateComputer.compute(pc)
# asserts rate2 ...
assert rate2.data_storage == 4.27 assert rate2.data_storage == 4.27
assert rate2.processor == 3.61 assert rate2.processor == 3.61
assert rate2.ram == 4.12 assert rate2.ram == 4.12
@ -206,7 +198,5 @@ def test_multiple_rates(user: UserClient):
assert rate2.functionality == -0.5 assert rate2.functionality == -0.5
assert rate2.rating == 3.37 assert rate2.rating == 3.37
# assert rate2.rating_range == 'Medium'
assert rate2.price.price == Decimal('67.4001') assert rate2.price.price == Decimal('67.4001')
assert math.isclose(price2.price, 67.40, rel_tol=0.001)

View File

@ -135,11 +135,18 @@ def test_export_keyboard(user: UserClient):
assert fixture_csv[1] == export_csv[1], 'Component information are not equal' assert fixture_csv[1] == export_csv[1], 'Component information are not equal'
# TODO JN fix why components also have all rate fields
def test_export_multiple_different_devices(user: UserClient): def test_export_multiple_different_devices(user: UserClient):
""" """
Test a export multiple different device types (like computers, keyboards, monitors, ...) Test function 'Export' of multiple different device types (like
computers, keyboards, monitors, etc..)
""" """
# Open fixture csv and transform to list
with Path(__file__).parent.joinpath('files').joinpath('multiples_devices.csv').open() \
as csv_file:
fixture_csv = list(csv.reader(csv_file))
for row in fixture_csv:
del row[8] # We remove the 'Registered in' column
# Post all devices snapshots # Post all devices snapshots
snapshot_pc, _ = user.post(file('real-eee-1001pxd.snapshot.11'), res=Snapshot) snapshot_pc, _ = user.post(file('real-eee-1001pxd.snapshot.11'), res=Snapshot)
snapshot_empty, _ = user.post(file('basic.snapshot'), res=Snapshot) snapshot_empty, _ = user.post(file('basic.snapshot'), res=Snapshot)
@ -148,32 +155,13 @@ def test_export_multiple_different_devices(user: UserClient):
csv_str, _ = user.get(res=documents.DocumentDef.t, csv_str, _ = user.get(res=documents.DocumentDef.t,
item='devices/', item='devices/',
query=[('filter', {'type': ['Computer', 'Keyboard', 'Monitor']})],
accept='text/csv') accept='text/csv')
f = StringIO(csv_str) f = StringIO(csv_str)
obj_csv = csv.reader(f, f) obj_csv = csv.reader(f, f)
export_csv = list(obj_csv) export_csv = list(obj_csv)
# Open fixture csv and transform to list for row in export_csv:
with Path(__file__).parent.joinpath('files').joinpath('multiples_devices.csv').open() \ del row[8]
as csv_file:
obj_csv = csv.reader(csv_file)
fixture_csv = list(obj_csv)
assert fixture_csv[0] == export_csv[0], 'Headers are not equal' assert fixture_csv == export_csv
max_range = max(len(export_csv), len(fixture_csv)) - 1
# check if all devices information is correct
for i in range(1, max_range):
if isinstance(datetime.strptime(export_csv[i][8], '%c'), datetime):
export_csv[i] = export_csv[i][:8] + export_csv[i][9:]
fixture_csv[i] = fixture_csv[i][:8] + fixture_csv[i][9:]
assert fixture_csv[i] == export_csv[i], 'Some fields are not equal'
@pytest.mark.xfail(reason='Debug why rate computed correctly but when get info change value')
def test_temp_rate_rating(user: UserClient):
snapshot, _ = user.post(file('real-eee-1001pxd.snapshot.11'), res=Snapshot)
from ereuse_devicehub.resources.device.models import Device
device, _ = user.get(res=Device, item=snapshot['device']['id'])
assert device['rate']['rating'] == 1.98

View File

@ -384,13 +384,18 @@ def test_test_data_storage(user: UserClient):
@pytest.mark.xfail(reason='Not implemented yet, new rate is need it') @pytest.mark.xfail(reason='Not implemented yet, new rate is need it')
def test_snapshot_computer_monitor(user: UserClient): def test_snapshot_computer_monitor(user: UserClient):
"""
Tests that a snapshot of computer monitor device create correctly.
"""
s = file('computer-monitor.snapshot') s = file('computer-monitor.snapshot')
snapshot_and_check(user, s, action_types=('RateMonitor',)) snapshot_and_check(user, s, action_types=('RateMonitor',))
# todo check that ManualRate has generated an AggregateRate
@pytest.mark.xfail(reason='Not implemented yet, new rate is need it') @pytest.mark.xfail(reason='Not implemented yet, new rate is need it')
def test_snapshot_mobile_smartphone_imei_manual_rate(user: UserClient): def test_snapshot_mobile_smartphone_imei_manual_rate(user: UserClient):
"""
Tests that a snapshot of smartphone device is creat correctly.
"""
s = file('smartphone.snapshot') s = file('smartphone.snapshot')
snapshot = snapshot_and_check(user, s, action_types=('VisualTest',)) snapshot = snapshot_and_check(user, s, action_types=('VisualTest',))
mobile, _ = user.get(res=m.Device, item=snapshot['device']['id']) mobile, _ = user.get(res=m.Device, item=snapshot['device']['id'])
@ -405,6 +410,7 @@ def test_snapshot_components_none():
""" """
# TODO JN is really necessary in which cases??
@pytest.mark.xfail(reason='Test not developed') @pytest.mark.xfail(reason='Test not developed')
def test_snapshot_components_empty(): def test_snapshot_components_empty():
""" """