From 928863bfdf11b66128a183987e97e43712380db2 Mon Sep 17 00:00:00 2001 From: Xavier Bustamante Talavera Date: Wed, 12 Jun 2019 16:49:55 +0200 Subject: [PATCH] Update comments in actions; remove workbench folder in rate --- docs/conf.py | 1 - ereuse_devicehub/resources/action/models.py | 166 ++++++------------ .../action/rate/{workbench => }/v1_0.py | 71 +++----- .../action/rate/workbench/__init__.py | 0 ereuse_devicehub/resources/action/views.py | 2 +- tests/test_rate_workbench_v1.py | 2 +- 6 files changed, 79 insertions(+), 163 deletions(-) rename ereuse_devicehub/resources/action/rate/{workbench => }/v1_0.py (84%) delete mode 100644 ereuse_devicehub/resources/action/rate/workbench/__init__.py diff --git a/docs/conf.py b/docs/conf.py index 43e4683c..d4cc7ab9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -211,7 +211,6 @@ class DhlistDirective(Directive): yield obj def run(self): - env = self.state.document.settings.env module = importlib.import_module(self.options['module']) things = tuple(self._import(module)) diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index cba0d1d1..64b7fd8a 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -645,17 +645,13 @@ class BenchmarkGraphicCard(BenchmarkWithRate): class Test(JoinedWithOneDeviceMixin, ActionWithOneDevice): - """The act of testing the physical condition of a device and its - components. + """The act of documenting the functionality of a device, as + for the R2 Standard (R2 Provision 6 pag.19). - Ref in R2 Provision 6 pag.19: - Records of test results are imperative to documenting - the functionality of each device. - Pass or fail results for each test in the process must be recorded - either manually or through software automation. - - Testing errors and warnings are easily taken in - :attr:`ereuse_devicehub.resources.device.models.Device.working`. + :attr:`.severity` in :class:`Action` defines a passing or failing + test, and + :attr:`ereuse_devicehub.resources.device.models.Device.working` + in Device gets all tests with warnings or errors for a device. """ @declared_attr @@ -681,23 +677,13 @@ class TestMixin: class MeasureBattery(TestMixin, Test): - """ - A sample of the status of the battery. + """A sample of the status of the battery. + Ref in R2 Provision 6 pag.22 Example: Length of charge; Expected results: Minimum 40 minutes. Operative Systems keep a record of several aspects of a battery. This is a sample of those. - - :class: 'Severtity' - Info/Pass(0): - - Notice(1): - - Warning(2): - - Error/Fail(3): - """ size = db.Column(db.Integer, nullable=False) size.comment = """Maximum battery capacity, in mAh.""" @@ -714,8 +700,7 @@ class MeasureBattery(TestMixin, Test): class TestDataStorage(TestMixin, Test): - """ - The act of testing the data storage. + """The act of testing the data storage. Testing is done using the `S.M.A.R.T self test `_. Note @@ -725,15 +710,11 @@ class TestDataStorage(TestMixin, Test): The test takes to other SMART values indicators of the overall health of the data storage. - :class: 'Severtity' - Info/Pass(0): - - Notice(1): - - Warning(2): - - Error/Fail(3): + Failing and warning conditions are as follows: + * :attr:`Severity.Error`: if the SMART test failed. + * :attr:`Severity.Warning`: if there is a significant chance for + the data storage to fail in the following year. """ length = Column(DBEnum(TestDataStorageLength), nullable=False) # todo from type status = Column(Unicode(), check_lower('status'), nullable=False) @@ -783,8 +764,7 @@ class TestDataStorage(TestMixin, Test): class StressTest(TestMixin, Test): """The act of stressing (putting to the maximum capacity) - a device for an amount of minutes. If the device is not in great - condition won't probably survive such test. + a device for an amount of minutes. """ elapsed = Column(Interval, nullable=False) @@ -800,20 +780,7 @@ class StressTest(TestMixin, Test): class TestAudio(TestMixin, Test): - """ - Test to check audio device aspects, focus on speaker sounds correctly - and microphone record sounds good - - :class: 'Severtity' - Info/Pass(0): - - Notice(1): - - Warning(2): - - Error/Fail(3): - - """ + """The act of checking the audio aspects of the device.""" _speaker = Column('speaker', Boolean) _speaker.comment = """Whether the speaker works as expected.""" _microphone = Column('microphone', Boolean) @@ -844,82 +811,68 @@ class TestAudio(TestMixin, Test): class TestConnectivity(TestMixin, Test): - """ - Tests that the device can connect both physically and wirelessly. + """The act of testing the connectivity of the device. A failing test means that at least one connection of the device is not working well. A comment should get into more detail. - - :class: 'Severtity' - Info/Pass(0): - - Notice(1): - - Warning(2): - - Error/Fail(3): - """ class TestCamera(TestMixin, Test): - """ - Tests the working conditions of the camera of the device, + """Tests the working conditions of the camera of the device, specially when taking pictures or recording video. - Fail when camera can't take pictures. + + Failing and warning conditions are as follows: + + * :attr:`Severity.Error`: if the camera cannot turn on or + has significant visual problems. + * :attr:`Severity.Warning`: if there are small visual problems + with the camera (like dust) that it still allows it to be used. """ class TestKeyboard(TestMixin, Test): - """ - Whether the keyboard works correctly. + """Whether the keyboard works correctly. - Ref in R2 Provision 6 pag.22 example: - PASS when each key produces character on the screen + Failing and warning conditions are as follows: + + * :attr:`Severity.Error`: if at least one key does not produce + a character on screen. This follows R2 Provision 6 pag.22. """ class TestTrackpad(TestMixin, Test): - """ - Whether the trackpad works correctly. + """Whether the trackpad works correctly. - Ref in R2 Provision 6 pag.22 example: - PASS when cursor moves on screen + Failing and warning conditions are as follows: + + * :attr:`Severity.Error`: if the cursor does not move on screen. + This follows R2 Provision 6 pag.22. """ -class TestScreenHinge(TestMixin, Test): - """ - Whether screen hinge works correctly. +class TestDisplayHinge(TestMixin, Test): + """Whether display hinge works correctly. - Laptop Test Ref in R2 Provision 6 pag.22 example: - PASS when laptop screen stays open/closed at desired angles + Failing and warning conditions are as follows: + + * :attr:`Severity.Error`: if the laptop does not stay open + or closed at desired angles. From R2 Provision 6 pag.22. """ class TestPowerAdapter(TestMixin, Test): - """ - Whether power adapter charge battery device without problems. + """Whether power adapter charge battery device without problems. - Laptop Test Ref in R2 Provision 6 pag.22 example: - PASS when plug power adapter into laptop and charges the battery. + Failing and warning conditions are as follows: + + * :attr:`Severity.Error`: if the laptop does not charge battery. + This follows R2 Provision 6 pag.22. """ class TestBios(TestMixin, Test): - """ - Tests the working condition and grades the usability of the BIOS. - - :class: 'Severtity' - Info/Pass(0): - - Notice(1): - - Warning(2): - - Error/Fail(3): - - """ + """Tests the working condition and grades the usability of the BIOS.""" beeps_power_on = Column(Boolean) beeps_power_on.comment = """Whether there are no beeps or error codes when booting up. @@ -935,25 +888,12 @@ class TestBios(TestMixin, Test): class VisualTest(TestMixin, Test): - """ - The act of visually inspecting the appearance and functionality + """The act of visually inspecting the appearance and functionality of the device. Reference R2 provision 6 Templates Ready for Resale Checklist (Desktop) https://sustainableelectronics.org/sites/default/files/6.c.2%20Desktop%20R2-Ready%20for%20Resale%20Checklist.docx Physical condition grade - - - :class: 'Severtity' - Info/Pass(0): - - Notice(1): - - Warning(2): - - Error/Fail(3): - - """ appearance_range = Column(DBEnum(AppearanceRange), nullable=False) appearance_range.comment = AppearanceRange.__doc__ @@ -970,13 +910,11 @@ class VisualTest(TestMixin, Test): class Rate(JoinedWithOneDeviceMixin, ActionWithOneDevice): - """ - The act of computing a rate based on different categories: - - • Functionality (F). Tests, the act of testing usage condition of a device - • Appearance (A). Visual evaluation, surface deterioration. - • Performance (Q). Components characteristics and components benchmarks. + """The act of computing a rate based on different categories: + * Functionality (F). Tests, the act of testing usage condition of a device + * Appearance (A). Visual evaluation, surface deterioration. + * Performance (Q). Components characteristics and components benchmarks. """ # todo jn: explain in each comment what the rate considers. N = 2 @@ -1128,7 +1066,7 @@ class RateComputer(RateMixin, Rate): """ The act of compute general computer rate """ - from ereuse_devicehub.resources.action.rate.workbench.v1_0 import rate_algorithm + from ereuse_devicehub.resources.action.rate.v1_0 import rate_algorithm rate = rate_algorithm.compute(device) price = None with suppress(InvalidRangeForPrice): # We will have exception if range == VERY_LOW diff --git a/ereuse_devicehub/resources/action/rate/workbench/v1_0.py b/ereuse_devicehub/resources/action/rate/v1_0.py similarity index 84% rename from ereuse_devicehub/resources/action/rate/workbench/v1_0.py rename to ereuse_devicehub/resources/action/rate/v1_0.py index c2395766..eb1050f7 100644 --- a/ereuse_devicehub/resources/action/rate/workbench/v1_0.py +++ b/ereuse_devicehub/resources/action/rate/v1_0.py @@ -12,54 +12,29 @@ from ereuse_devicehub.resources.device.models import Computer, DataStorage, Proc class RateAlgorithm(BaseRate): """The algorithm that generates the Rate v1.0. - Rate v1.0 is mainly based on 3 components (Processor, RAM and Data Storage) - and 2 visual grades (one for appearance aspects and other for functionality aspects). + Rate v1.0 rates only computers, counting their processor, ram, + data storage, appearance, and functionality. This rate is only + triggered by a Snapshot from Workbench that has a VisualTest. + The algorithm is as follows: - From components we take into account their main characteristics and - also some tests and benchmarks. In particular: + 1. Specialized subclasses of :class:`BaseRate` compute a rating + for each component. To perform this, each class normalizes first + the characteristics and benchmarks of the components between + 0 and 1, and then they merge the values to a resulting score. + The classes are: - * Processor: - - Cores - - Speed - - Benchmark processor - - * RAM: - - Size - - Speed - - * Data Storage: - - Size - - Benchmark data storage (Read and write speed) - - Step by step to compute Rate v1.0: - - 1. Normalization the components characteristics. - Normalized the characteristics of the components between 0 and 1. - with xMin and xMax and standardize the values applying - the following formula: - - **Normalization characteristic value = (x −xMin)/(xMax −xMin)** - - 2. Merge the characteristics of every component in one score for component. - - - 3. Merge the components individual rates into a single components rate. - We calculate this rate using the weighted harmonic mean. - We establish all the components weights, 50% for processor, - 20% for data storage, 30% for RAM. - The result is a unique performance score (components rate). - - 4. Grouping all categories aspects sum all in unique final rate. - To get Functionality and Appearance Rates values, only directly - related a value for each grade. - - **Final Rate = Components Rate + Functionality Rate + Appearance Rate** - - Final Rate are ranged from 0 to 4.7. - - Do not call directly this class, but use - :meth:`ereuse_devicehub.resources.action.models.RateComputer.compute`, - which then calls this. + * :class:`ProcessorRate`, using cores, speed, and ``BenchmarkProcessor``. + * :class:`RamRate`, using the total of RAM size and speed. + * :class:`DataStorageRate`, using the total of disk capacity, + and ``BenchmarkDataStorage``. + 2. Merge the components individual rates into a single rate for + all components, using a weighted harmonic mean of + 50% for the processor rating, 20% for the data storage rating, + and 30% for the RAM rating. + 3. Merge the rate for the components with the appearance and + functionality from :class:`VisualTest`. ``Final Rate = + Components Rate + Functionality Rate + Appearance Rate``. The + value is between 0 and 4.7, included. """ @unique @@ -91,6 +66,10 @@ class RateAlgorithm(BaseRate): """Generates a new :class:`ereuse_devicehub.resources.action.models.RateComputer` for the passed-in device. + + Do not call directly this class, but use + :meth:`ereuse_devicehub.resources.action.models.RateComputer.compute`, + which then calls this. """ assert isinstance(device, Computer), 'Can only rate computers' diff --git a/ereuse_devicehub/resources/action/rate/workbench/__init__.py b/ereuse_devicehub/resources/action/rate/workbench/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index 42c50dc2..c844b2fc 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -9,7 +9,7 @@ from teal.resource import View from ereuse_devicehub.db import db from ereuse_devicehub.resources.action.models import Action, RateComputer, Snapshot, VisualTest -from ereuse_devicehub.resources.action.rate.workbench.v1_0 import CannotRate +from ereuse_devicehub.resources.action.rate.v1_0 import CannotRate from ereuse_devicehub.resources.device.models import Component, Computer from ereuse_devicehub.resources.enums import SnapshotSoftware diff --git a/tests/test_rate_workbench_v1.py b/tests/test_rate_workbench_v1.py index f39e2dca..2ccbf0fd 100644 --- a/tests/test_rate_workbench_v1.py +++ b/tests/test_rate_workbench_v1.py @@ -23,7 +23,7 @@ import pytest from ereuse_devicehub.resources.action.models import BenchmarkDataStorage, BenchmarkProcessor, \ VisualTest -from ereuse_devicehub.resources.action.rate.workbench.v1_0 import DataStorageRate, ProcessorRate, \ +from ereuse_devicehub.resources.action.rate.v1_0 import DataStorageRate, ProcessorRate, \ RamRate, RateAlgorithm from ereuse_devicehub.resources.device.models import Desktop, HardDrive, Processor, RamModule from ereuse_devicehub.resources.enums import AppearanceRange, ComputerChassis, FunctionalityRange