Fix bug when device rate is low

This commit is contained in:
Xavier Bustamante Talavera 2018-10-14 23:56:54 +02:00
parent 2aaa79e8b4
commit 97536c5ce1
4 changed files with 148 additions and 6 deletions

View file

@ -563,8 +563,9 @@ class EreusePrice(Price):
def __init__(self, device, rating_range, role, price) -> None:
cls = device.__class__ if device.__class__ != Server else Desktop
rate = self.SCHEMA[cls][rating_range]
self.standard = EreusePrice.Type(rate['STD'][role], price)
self.warranty2 = EreusePrice.Type(rate['WR2'][role], price)
self.standard = EreusePrice.Type(rate[self.STANDARD][role], price)
if self.WARRANTY2 in rate:
self.warranty2 = EreusePrice.Type(rate[self.WARRANTY2][role], price)
def __init__(self, rating: AggregateRate, **kwargs) -> None:
if rating.rating_range == RatingRange.VERY_LOW:
@ -584,9 +585,10 @@ class EreusePrice(Price):
self.refurbisher = self._service(self.Service.REFURBISHER)
self.retailer = self._service(self.Service.RETAILER)
self.platform = self._service(self.Service.PLATFORM)
self.warranty2 = round(self.refurbisher.warranty2.amount
+ self.retailer.warranty2.amount
+ self.platform.warranty2.amount, 2)
if hasattr(self.refurbisher, 'warranty2'):
self.warranty2 = round(self.refurbisher.warranty2.amount
+ self.retailer.warranty2.amount
+ self.platform.warranty2.amount, 2)
def _service(self, role):
return self.Service(self.device, self.rating.rating_range, role, self.price)

View file

@ -262,7 +262,7 @@ class EreusePrice(Price):
MULTIPLIER = ... # type: Dict
class Type:
def __init__(self) -> None:
def __init__(self, percentage, price) -> None:
super().__init__()
self.amount = ... # type: float
self.percentage = ... # type: float

View file

@ -0,0 +1,134 @@
{
"closed": true,
"components": [
{
"events": [],
"manufacturer": "Intel Corporation",
"model": "NM10/ICH7 Family High Definition Audio Controller",
"serialNumber": null,
"type": "SoundCard"
},
{
"events": [],
"manufacturer": "Azurewave",
"model": "USB 2.0 UVC VGA WebCam",
"serialNumber": "0x0001",
"type": "SoundCard"
},
{
"events": [],
"format": "DIMM",
"interface": "DDR2",
"manufacturer": null,
"model": null,
"serialNumber": null,
"size": 1024,
"speed": 667.0,
"type": "RamModule"
},
{
"address": 64,
"cores": 1,
"events": [
{
"elapsed": 165,
"rate": 164.8342,
"type": "BenchmarkProcessorSysbench"
},
{
"elapsed": 0,
"rate": 6665.7,
"type": "BenchmarkProcessor"
}
],
"manufacturer": "Intel Corp.",
"model": "Intel Atom CPU N455 @ 1.66GHz",
"serialNumber": null,
"speed": 1.667,
"threads": 2,
"type": "Processor"
},
{
"events": [
{
"elapsed": 16,
"readSpeed": 66.2,
"type": "BenchmarkDataStorage",
"writeSpeed": 21.8
}
],
"interface": "ATA",
"manufacturer": "Hitachi",
"model": "HTS54322",
"serialNumber": "E2024242CV86HJ",
"size": 238475,
"type": "HardDrive"
},
{
"events": [],
"manufacturer": "Qualcomm Atheros",
"model": "AR9285 Wireless Network Adapter",
"serialNumber": "74:2f:68:8b:fd:c8",
"type": "NetworkAdapter",
"wireless": true
},
{
"events": [],
"manufacturer": "Qualcomm Atheros",
"model": "AR8152 v2.0 Fast Ethernet",
"serialNumber": "14:da:e9:42:f6:7c",
"speed": 100,
"type": "NetworkAdapter",
"wireless": false
},
{
"events": [],
"manufacturer": "Intel Corporation",
"memory": 256.0,
"model": "Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller",
"serialNumber": null,
"type": "GraphicCard"
},
{
"events": [],
"firewire": 0,
"manufacturer": "ASUSTeK Computer INC.",
"model": "1001PXD",
"pcmcia": 0,
"serial": 1,
"serialNumber": "Eee0123456789",
"slots": 2,
"type": "Motherboard",
"usb": 5
}
],
"device": {
"chassis": "Netbook",
"events": [
{
"elapsed": 16,
"rate": 15.8978,
"type": "BenchmarkRamSysbench"
},
{
"appearanceRange": "A",
"biosRange": "A",
"functionalityRange": "A",
"type": "WorkbenchRate"
}
],
"manufacturer": "ASUSTeK Computer INC.",
"model": "1001PXD",
"serialNumber": "B8OAAS048286",
"type": "Laptop"
},
"elapsed": 6,
"endTime": "2018-10-14T21:22:14.777235+00:00",
"expectedEvents": [
"Benchmark"
],
"software": "Workbench",
"type": "Snapshot",
"uuid": "7dc4d19c-914e-4652-a381-d641325fb9c2",
"version": "11.0a6"
}

View file

@ -294,3 +294,9 @@ def test_workbench_fixtures(file: pathlib.Path, user: UserClient):
user.post(res=em.Snapshot,
data=s,
status=201 if file.name not in SNAPSHOTS_NEED_ID else NeedsId)
def test_workbench_asus_1001pxd_rate_low(user: UserClient):
"""Tests an Asus 1001pxd with a low rate."""
s = file('asus-1001pxd.snapshot')
snapshot, _ = user.post(res=em.Snapshot, data=s)