From 75b5a4a710ac2b24d2f3ba290aad3fd750b8d8a9 Mon Sep 17 00:00:00 2001 From: nad Date: Thu, 15 Oct 2020 13:19:47 +0200 Subject: [PATCH] Adding test and fix for Issue 69 EreusePrice Computer type --- ereuse_devicehub/resources/action/models.py | 3 ++- tests/conftest.py | 6 ++++++ tests/test_workbench.py | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index 6e728ab1..a0d38e14 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -1163,6 +1163,7 @@ class EreusePrice(Price): value agreed by a circuit or platform. """ MULTIPLIER = { + Computer: 20, Desktop: 20, 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: cls = device.__class__ if device.__class__ != Server else Desktop diff --git a/tests/conftest.py b/tests/conftest.py index bdae5797..9969be22 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -134,6 +134,12 @@ def file(name: str) -> dict: 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() def tag_id(app: Devicehub) -> str: """Creates a tag and returns its id.""" diff --git a/tests/test_workbench.py b/tests/test_workbench.py index 3620e951..cefd294e 100644 --- a/tests/test_workbench.py +++ b/tests/test_workbench.py @@ -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.models import Device from ereuse_devicehub.resources.tag.model import Tag -from tests.conftest import file +from tests.conftest import file, file_workbench @pytest.mark.mvp @@ -328,3 +328,8 @@ def test_workbench_asus_1001pxd_rate_low(user: UserClient): def test_david(user: UserClient): s = file('david.lshw.snapshot') 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)