Adding test and fix for Issue 69 EreusePrice Computer type

This commit is contained in:
nad 2020-10-15 13:19:47 +02:00
parent a7c3ea7317
commit 75b5a4a710
3 changed files with 14 additions and 2 deletions

View File

@ -1163,6 +1163,7 @@ class EreusePrice(Price):
value agreed by a circuit or platform. value agreed by a circuit or platform.
""" """
MULTIPLIER = { MULTIPLIER = {
Computer: 20,
Desktop: 20, Desktop: 20,
Laptop: 30 Laptop: 30
} }
@ -1205,7 +1206,7 @@ class EreusePrice(Price):
} }
} }
} }
SCHEMA[Server] = SCHEMA[Desktop] SCHEMA[Server] = SCHEMA[Computer] = SCHEMA[Desktop]
def __init__(self, device, rating_range, role, price: Decimal) -> None: def __init__(self, device, rating_range, role, price: Decimal) -> None:
cls = device.__class__ if device.__class__ != Server else Desktop cls = device.__class__ if device.__class__ != Server else Desktop

View File

@ -134,6 +134,12 @@ def file(name: str) -> dict:
return yaml.load(f) return yaml.load(f)
def file_workbench(name: str) -> dict:
"""Opens and parses a YAML file from the ``files`` subdir."""
with Path(__file__).parent.joinpath('workbench_files').joinpath(name + '.json').open() as f:
return yaml.load(f)
@pytest.fixture() @pytest.fixture()
def tag_id(app: Devicehub) -> str: def tag_id(app: Devicehub) -> str:
"""Creates a tag and returns its id.""" """Creates a tag and returns its id."""

View File

@ -11,7 +11,7 @@ from ereuse_devicehub.resources.action.models import RateComputer, BenchmarkProc
from ereuse_devicehub.resources.device.exceptions import NeedsId from ereuse_devicehub.resources.device.exceptions import NeedsId
from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
from tests.conftest import file from tests.conftest import file, file_workbench
@pytest.mark.mvp @pytest.mark.mvp
@ -328,3 +328,8 @@ def test_workbench_asus_1001pxd_rate_low(user: UserClient):
def test_david(user: UserClient): def test_david(user: UserClient):
s = file('david.lshw.snapshot') s = file('david.lshw.snapshot')
snapshot, _ = user.post(res=em.Snapshot, data=s) snapshot, _ = user.post(res=em.Snapshot, data=s)
def test_eresueprice_computer_type(user: UserClient):
s = file_workbench('computer-type.snapshot')
snapshot, _ = user.post(res=em.Snapshot, data=s)