def test_rate_data_storage_rate():
    """
    Test to check if compute data storage rate have same value than previous score version;
    id = pc_1193, pc_1201, pc_79, pc_798
    """

    hdd_1969 = HardDrive(size=476940)
    hdd_1969.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))

    data_storage_rate = DataStorageRate().compute([hdd_1969], WorkbenchRate())

    assert math.isclose(data_storage_rate, 4.02, rel_tol=0.001), 'DataStorageRate returns incorrect value(rate)'

    hdd_3054 = HardDrive(size=476940)
    hdd_3054.events_one.add(BenchmarkDataStorage(read_speed=158, write_speed=34.7))

    # calculate DataStorage Rate
    data_storage_rate = DataStorageRate().compute([hdd_3054], WorkbenchRate())

    assert math.isclose(data_storage_rate, 4.07, rel_tol=0.001), 'DataStorageRate returns incorrect value(rate)'

    hdd_81 = HardDrive(size=76319)
    hdd_81.events_one.add(BenchmarkDataStorage(read_speed=72.2, write_speed=24.3))

    data_storage_rate = DataStorageRate().compute([hdd_81], WorkbenchRate())

    assert math.isclose(data_storage_rate, 2.61, rel_tol=0.001), 'DataStorageRate returns incorrect value(rate)'

    hdd_1556 = HardDrive(size=152587)
    hdd_1556.events_one.add(BenchmarkDataStorage(read_speed=78.1, write_speed=24.4))

    data_storage_rate = DataStorageRate().compute([hdd_1556], WorkbenchRate())

    assert math.isclose(data_storage_rate, 3.70, rel_tol=0.001), 'DataStorageRate returns incorrect value(rate)'
Exemple #2
0
def test_main():
    rate = WorkbenchRate(
        appearance_range=AppearanceRange.A,
        functionality_range=FunctionalityRange.A
    )
    pc = Desktop()
    hdd = HardDrive(size=476940)
    hdd.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))
    cpu = Processor(cores=2, speed=3.4)
    cpu.events_one.add(BenchmarkProcessor(rate=27136.44))
    pc.components |= {
        hdd,
        RamModule(size=4096, speed=1600),
        RamModule(size=2048, speed=1067),
        cpu
    }
    rate.device = pc
    events = main.main(rate, RatingSoftware.ECost, StrictVersion('1.0'))
    price = next(e for e in events if isinstance(e, EreusePrice))
    assert price.price == 92.2
    assert price.retailer.standard.amount == 40.97
    assert price.platform.standard.amount == 18.84
    assert price.refurbisher.standard.amount == 32.38
    assert price.price >= price.retailer.standard.amount \
           + price.platform.standard.amount \
           + price.refurbisher.standard.amount
    assert price.retailer.warranty2.amount == 55.30
    assert price.platform.warranty2.amount == 25.43
    assert price.refurbisher.warranty2.amount == 43.72
    assert price.warranty2 == 124.45
    # Checks relationships
    workbench_rate = next(e for e in events if isinstance(e, WorkbenchRate))
    aggregate_rate = next(e for e in events if isinstance(e, AggregateRate))
    assert price.rating == aggregate_rate
    assert aggregate_rate.ratings[0] == workbench_rate
def test_ram_speed_is_null():
    """
    Test where RamModule.speed is NULL (not detected) but has size.
    Pc ID = 795(1542), 745(1535), 804(1549)
    """

    ram0 = RamModule(size=2048, speed=None)

    ram_rate = RamRate().compute([ram0], WorkbenchRate())

    assert round(ram_rate, 2) == 1.85, 'RamRate returns incorrect value(rate)'

    ram0 = RamModule(size=1024, speed=None)

    ram_rate = RamRate().compute([ram0], WorkbenchRate())

    assert round(ram_rate, 2) == 1.25, 'RamRate returns incorrect value(rate)'
def test_no_ram_module():
    """
    Test without RamModule
    """
    ram0 = RamModule()

    ram_rate = RamRate().compute([ram0], WorkbenchRate())
    assert ram_rate is None
def test_no_data_storage():
    """
    Test without data storage devices
    """
    hdd_null = HardDrive()
    hdd_null.events_one.add(BenchmarkDataStorage(read_speed=0, write_speed=0))
    data_storage_rate = DataStorageRate().compute([hdd_null], WorkbenchRate())
    assert data_storage_rate is None
Exemple #6
0
def main(rating_model: WorkbenchRate,
         software: RatingSoftware,
         version: StrictVersion) -> Set[Union[WorkbenchRate, AggregateRate, EreusePrice]]:
    """
    Generates all the rates (per software and version) for a given
    half-filled rate acting as a model, and finally it generates
    an ``AggregateRating`` with the rate that matches the
    ``software`` and ``version``.

    This method mutates ``rating_model`` by fulfilling it and
    ``rating_model.device`` by adding the new rates.

    :return: A set of rates with the ``rate`` value computed, where
             the first rate is the ``rating_model``.
    """
    assert rating_model.device
    events = set()
    for soft, value in RATE_TYPES[rating_model.__class__].items():
        for vers, func in value.items():
            if not rating_model.rating:  # Fill the rating before creating another rate
                rating = rating_model
            else:  # original rating was filled already; use a new one
                rating = WorkbenchRate(
                    labelling=rating_model.labelling,
                    appearance_range=rating_model.appearance_range,
                    functionality_range=rating_model.functionality_range,
                    device=rating_model.device,
                )
            rating.software = soft
            rating.version = vers
            rate(rating_model.device, rating)
            events.add(rating)
            if soft == software and vers == version:
                aggregation = AggregateRate(
                    software=rating.software,
                    rating=rating.rating,
                    version=StrictVersion('1.0'),
                    device=rating_model.device
                )
                aggregation.ratings.add(rating)
                events.add(aggregation)
                with suppress(ValueError):
                    # We will have exception if range == VERY_LOW
                    events.add(EreusePrice(aggregation))
    return events
def test_ram_module_size_is_0():
    """
    Test where input data RamModule.size = 0; is like no RamModule has been detected; id =  pc_798
    """

    ram0 = RamModule(size=0, speed=888)

    ram_rate = RamRate().compute([ram0], WorkbenchRate())
    assert ram_rate is None
def test_rate_ram_speed_is_null():
    """
    Test where RamModule.speed is NULL (not detected) but has size.
    Pc ID = 795(1542), 745(1535), 804(1549)
    """

    ram0 = RamModule(size=2048, speed=None)

    ram_rate = RamRate().compute([ram0], WorkbenchRate())

    assert math.isclose(ram_rate, 1.85, rel_tol=0.002), 'RamRate returns incorrect value(rate)'

    ram0 = RamModule(size=1024, speed=None)

    ram_rate = RamRate().compute([ram0], WorkbenchRate())

    # todo rel_tol >= 0.004
    assert math.isclose(ram_rate, 1.25, rel_tol=0.004), 'RamRate returns incorrect value(rate)'
Exemple #9
0
def test_rate():
    """Test generating an AggregateRate for a given PC / components /
    WorkbenchRate ensuring results and relationships between
    pc - rate - workbenchRate - price.
    """
    rate = WorkbenchRate(appearance_range=AppearanceRange.A,
                         functionality_range=FunctionalityRange.A)
    pc = Desktop(chassis=ComputerChassis.Tower)
    hdd = HardDrive(size=476940)
    hdd.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))
    cpu = Processor(cores=2, speed=3.4)
    cpu.events_one.add(BenchmarkProcessor(rate=27136.44))
    pc.components |= {
        hdd,
        RamModule(size=4096, speed=1600),
        RamModule(size=2048, speed=1067), cpu
    }
    rate.device = pc
    events = main.main(rate, RatingSoftware.ECost, StrictVersion('1.0'))
    price = next(e for e in events if isinstance(e, EreusePrice))
    assert price.price == Decimal('92.2001')
    assert price.retailer.standard.amount == Decimal('40.9714')
    assert price.platform.standard.amount == Decimal('18.8434')
    assert price.refurbisher.standard.amount == Decimal('32.3853')
    assert price.price >= price.retailer.standard.amount \
           + price.platform.standard.amount \
           + price.refurbisher.standard.amount
    assert price.retailer.warranty2.amount == Decimal('55.3085')
    assert price.platform.warranty2.amount == Decimal('25.4357')
    assert price.refurbisher.warranty2.amount == Decimal('43.7259')
    assert price.warranty2 == Decimal('124.47')
    # Checks relationships
    workbench_rate = next(e for e in events if isinstance(e, WorkbenchRate))
    aggregate_rate = next(e for e in events if isinstance(e, AggregateRate))
    assert price.rating == aggregate_rate
    assert aggregate_rate.workbench == workbench_rate
    assert aggregate_rate.rating == workbench_rate.rating == 4.61
    assert aggregate_rate.software == workbench_rate.software == RatingSoftware.ECost
    assert aggregate_rate.version == StrictVersion('1.0')
    assert aggregate_rate.appearance == workbench_rate.appearance
    assert aggregate_rate.functionality == workbench_rate.functionality
    assert aggregate_rate.rating_range == workbench_rate.rating_range
    assert cpu.rate == pc.rate == hdd.rate == aggregate_rate
    assert cpu.price == pc.price == aggregate_rate.price == hdd.price == price
Exemple #10
0
def test_processor_with_null_cores():
    """
    Test with processor device have null number of cores
    """
    cpu = Processor(cores=None, speed=3.3)
    cpu.events_one.add(BenchmarkProcessor(rate=0))

    processor_rate = ProcessorRate().compute(cpu, WorkbenchRate())

    assert processor_rate == 1, 'ProcessorRate returns incorrect value(rate)'
Exemple #11
0
def test_processor_with_null_speed():
    """
    Test with processor device have null speed value
    """
    cpu = Processor(cores=1, speed=None)
    cpu.events_one.add(BenchmarkProcessor(rate=0))

    processor_rate = ProcessorRate().compute(cpu, WorkbenchRate())

    assert processor_rate == 1.06, 'ProcessorRate returns incorrect value(rate)'
Exemple #12
0
def test_ram_rate():
    """
    Test to check if compute ram rate have same value than previous score version
    only with 1 RamModule; id = pc_1201
    """

    ram1 = RamModule(size=2048, speed=1333)

    ram_rate = RamRate().compute([ram1], WorkbenchRate())

    assert round(ram_rate, 2) == 2.02, 'RamRate returns incorrect value(rate)'
def test_rate_ram_rate():
    """
    Test to check if compute ram rate have same value than previous score version
    only with 1 RamModule; id = pc_1201
    """

    ram1 = RamModule(size=2048, speed=1333)

    ram_rate = RamRate().compute([ram1], WorkbenchRate())

    # todo rel_tol >= 0.002
    assert math.isclose(ram_rate, 2.02, rel_tol=0.002), 'RamRate returns incorrect value(rate)'
Exemple #14
0
def test_data_storage_size_is_null():
    """
    Test where input DataStorage.size = NULL, BenchmarkDataStorage.read_speed = 0,
    BenchmarkDataStorage.write_speed = 0 is like no DataStorage has been detected;
    id = pc_2992
    """

    hdd_null = HardDrive(size=None)
    hdd_null.events_one.add(BenchmarkDataStorage(read_speed=0, write_speed=0))

    data_storage_rate = DataStorageRate().compute([hdd_null], WorkbenchRate())
    assert data_storage_rate is None
def test_rate_processor_rate_2cores():
    """
    Test to check if compute processor rate have same value than previous score version
    with 2 cores; id = pc_1193, pc_1201
    """

    cpu = Processor(cores=2, speed=3.4)
    # add score processor benchmark
    cpu.events_one.add(BenchmarkProcessor(rate=27136.44))

    processor_rate = ProcessorRate().compute(cpu, WorkbenchRate())

    assert math.isclose(processor_rate, 3.95, rel_tol=0.001), 'ProcessorRate returns incorrect value(rate)'

    cpu = Processor(cores=2, speed=3.3)
    cpu.events_one.add(BenchmarkProcessor(rate=26339.48))

    processor_rate = ProcessorRate().compute(cpu, WorkbenchRate())

    # todo rel_tol >= 0.002
    assert math.isclose(processor_rate, 3.93, rel_tol=0.002), 'ProcessorRate returns incorrect value(rate)'
def test_rate_processor_with_null_cores():
    """
    Test with processor device have null number of cores
    """
    cpu = Processor(cores=None, speed=3.3)
    # todo try without BenchmarkProcessor, StopIteration problem
    cpu.events_one.add(BenchmarkProcessor())

    processor_rate = ProcessorRate().compute(cpu, WorkbenchRate())

    # todo rel_tol >= 0.003
    assert math.isclose(processor_rate, 1.38, rel_tol=0.003), 'ProcessorRate returns incorrect value(rate)'
Exemple #17
0
def test_ram_rate_2modules():
    """
    Test to check if compute ram rate have same value than previous score version
    with 2 RamModule; id = pc_1193
    """

    ram1 = RamModule(size=4096, speed=1600)
    ram2 = RamModule(size=2048, speed=1067)

    ram_rate = RamRate().compute([ram1, ram2], WorkbenchRate())

    assert round(ram_rate, 2) == 3.79, 'RamRate returns incorrect value(rate)'
Exemple #18
0
def test_workbench_rate():
    rate = WorkbenchRate(processor=0.1,
                         ram=1.0,
                         bios=Bios.A,
                         labelling=False,
                         graphic_card=0.1,
                         data_storage=4.1,
                         algorithm_software=RatingSoftware.Ereuse,
                         algorithm_version=StrictVersion('1.0'),
                         device=Microtower(serial_number='24'))
    db.session.add(rate)
    db.session.commit()
Exemple #19
0
def test_processor_rate():
    """
    Test to check if compute processor rate have same value than previous score version
    only with 1 core; id = 79
    """

    cpu = Processor(cores=1, speed=1.6)
    # add score processor benchmark
    cpu.events_one.add(BenchmarkProcessor(rate=3192.34))

    processor_rate = ProcessorRate().compute(cpu, WorkbenchRate())

    assert processor_rate == 1, 'ProcessorRate returns incorrect value(rate)'
Exemple #20
0
def test_workbench_rate_db():
    rate = WorkbenchRate(processor=0.1,
                         ram=1.0,
                         bios_range=Bios.A,
                         labelling=False,
                         graphic_card=0.1,
                         data_storage=4.1,
                         software=RatingSoftware.ECost,
                         version=StrictVersion('1.0'),
                         device=Computer(serial_number='24',
                                         chassis=ComputerChassis.Tower))
    db.session.add(rate)
    db.session.commit()
Exemple #21
0
def test_ram_rate_4modules():
    """
    Test to check if compute ram rate have same value than previous score version
    with 2 RamModule; id = pc_79
    """

    ram1 = RamModule(size=512, speed=667)
    ram2 = RamModule(size=512, speed=800)
    ram3 = RamModule(size=512, speed=667)
    ram4 = RamModule(size=512, speed=533)

    ram_rate = RamRate().compute([ram1, ram2, ram3, ram4], WorkbenchRate())

    assert round(ram_rate, 2) == 1.99, 'RamRate returns incorrect value(rate)'
def test_rate_ram_rate_4modules():
    """
    Test to check if compute ram rate have same value than previous score version
    with 2 RamModule; id = pc_79
    """

    ram1 = RamModule(size=512, speed=667)
    ram2 = RamModule(size=512, speed=800)
    ram3 = RamModule(size=512, speed=667)
    ram4 = RamModule(size=512, speed=533)

    ram_rate = RamRate().compute([ram1, ram2, ram3, ram4], WorkbenchRate())

    # todo rel_tol >= 0.002
    assert math.isclose(ram_rate, 1.993, rel_tol=0.001), 'RamRate returns incorrect value(rate)'
Exemple #23
0
def test_rate():
    """
    Test main rate function
    """
    pc = Desktop()
    hdd = HardDrive(size=476940)
    hdd.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))
    cpu = Processor(cores=2, speed=3.4)
    cpu.events_one.add(BenchmarkProcessor(rate=27136.44))
    pc.components |= {
        hdd,
        RamModule(size=4096, speed=1600),
        RamModule(size=2048, speed=1067),
        cpu
    }
    rate = WorkbenchRate(appearance_range=AppearanceRange.A,
                         software=RatingSoftware.ECost,
                         version=StrictVersion('1.0'),
                         functionality_range=FunctionalityRange.A)
    rate.algorithm_version = StrictVersion('1.0')

    main.rate(pc, rate)

    assert rate.rating == 4.61
Exemple #24
0
    def compute(self, device: Computer, rate: WorkbenchRate):
        """
        Compute 'Workbench'Rate computer is a rate (score) ranging from 0 to 4.7
        that represents estimating value of use of desktop and laptop computer components.

        This mutates "rate".
        """
        assert isinstance(device, (Desktop, Laptop, Server))
        assert isinstance(rate, WorkbenchRate)

        rate.processor = rate.data_storage = rate.ram = 1  # Init

        # Group cpus, rams, storages and compute their rate
        # Treat the same way with HardDrive and SolidStateDrive like (DataStorage)
        clause = lambda x: DataStorage.t if isinstance(x, DataStorage) else x.t
        c = (c for c in device.components
             if clause(c) in set(self.RATES.keys()))
        for type, components in groupby(sorted(c, key=clause), key=clause):
            if type == Processor.t:  # ProcessorRate.compute expects only 1 processor
                components = next(components)
            field, rate_cls = self.RATES[type]  # type: str, BaseRate
            result = rate_cls.compute(components, rate)
            if result:
                setattr(rate, field, result)

        rate_components = self.harmonic_mean_rates(rate.processor,
                                                   rate.data_storage, rate.ram)
        rate.appearance = self.Appearance.from_devicehub(
            rate.appearance_range).value
        rate.functionality = self.Functionality.from_devicehub(
            rate.functionality_range).value

        rate.rating = round(
            max(rate_components + rate.functionality + rate.appearance, 0), 2)
        rate.appearance = round(rate.appearance, 2)
        rate.functionality = round(rate.functionality, 2)
        rate.processor = round(rate.processor, 2)
        rate.ram = round(rate.ram, 2)
        rate.data_storage = round(rate.data_storage, 2)
def test_snapshot_model():
    """
    Tests creating a Snapshot with its relationships ensuring correct
    DB mapping.
    """
    device = Microtower(serial_number='a1')
    # noinspection PyArgumentList
    snapshot = Snapshot(uuid=uuid4(),
                        date=datetime.now(),
                        version='1.0',
                        software=SnapshotSoftware.DesktopApp,
                        elapsed=timedelta(seconds=25))
    snapshot.device = device
    snapshot.request = SnapshotRequest(request={'foo': 'bar'})
    snapshot.events.add(
        WorkbenchRate(processor=0.1,
                      ram=1.0,
                      bios=Bios.A,
                      labelling=False,
                      graphic_card=0.1,
                      data_storage=4.1,
                      algorithm_software=RatingSoftware.Ereuse,
                      algorithm_version=StrictVersion('1.0'),
                      device=device))
    db.session.add(snapshot)
    db.session.commit()
    device = Microtower.query.one()  # type: Microtower
    e1, e2 = device.events
    assert isinstance(
        e1, Snapshot), 'Creation order must be preserved: 1. snapshot, 2. WR'
    assert isinstance(e2, WorkbenchRate)
    db.session.delete(device)
    db.session.commit()
    assert Snapshot.query.one_or_none() is None
    assert SnapshotRequest.query.one_or_none() is None
    assert User.query.one() is not None
    assert Microtower.query.one_or_none() is None
    assert Device.query.one_or_none() is None
Exemple #26
0
def test_computer_rate():
    """
    Test Rate v1
    """
    # Create a new Computer with components characteristics of pc with id = 1193
    pc_test = Desktop()
    data_storage = HardDrive(size=476940)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))
    cpu = Processor(cores=2, speed=3.4)
    cpu.events_one.add(BenchmarkProcessor(rate=27136.44))
    pc_test.components |= {
        data_storage,
        RamModule(size=4096, speed=1600),
        RamModule(size=2048, speed=1067),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.A,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert round(rate_pc.ram, 2) == 3.79

    assert round(rate_pc.data_storage, 2) == 4.02

    assert round(rate_pc.processor, 2) == 3.95

    assert round(rate_pc.rating, 2) == 4.61

    # Create a new Computer with components characteristics of pc with id = 1201
    pc_test = Desktop()
    data_storage = HardDrive(size=476940)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=158, write_speed=34.7))
    cpu = Processor(cores=2, speed=3.3)
    cpu.events_one.add(BenchmarkProcessor(rate=26339.48))
    pc_test.components |= {
        data_storage,
        RamModule(size=2048, speed=1333),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.B,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert round(rate_pc.ram, 2) == 2.02

    assert round(rate_pc.data_storage, 2) == 4.07

    assert round(rate_pc.processor, 2) == 3.93

    assert round(rate_pc.rating, 2) == 3.48

    # Create a new Computer with components characteristics of pc with id = 79
    pc_test = Desktop()
    data_storage = HardDrive(size=76319)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=72.2, write_speed=24.3))
    cpu = Processor(cores=1, speed=1.6)
    cpu.events_one.add(BenchmarkProcessor(rate=3192.34))
    pc_test.components |= {
        data_storage,
        RamModule(size=512, speed=667),
        RamModule(size=512, speed=800),
        RamModule(size=512, speed=667),
        RamModule(size=512, speed=533),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.C,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert round(rate_pc.ram, 2) == 1.99

    assert round(rate_pc.data_storage, 2) == 2.61

    assert round(rate_pc.processor, 2) == 1

    assert round(rate_pc.rating, 2) == 1.58

# Create a new Computer with components characteristics of pc with id = 798
    pc_test = Desktop()
    data_storage = HardDrive(size=152587)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=78.1, write_speed=24.4))
    cpu = Processor(cores=2, speed=2.5)
    cpu.events_one.add(BenchmarkProcessor(rate=9974.3))
    pc_test.components |= {
        data_storage,
        RamModule(size=0, speed=None),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.B,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert round(rate_pc.ram, 2) == 1

    assert round(rate_pc.data_storage, 2) == 3.7

    assert round(rate_pc.processor, 2) == 4.09

    assert round(rate_pc.rating, 2) == 2.5
def test_rate_computer_rate():
    """ Test rate v1
    
        pc_1193 = Computer()
        price = 92.2
        # add components characteristics of pc with id = 1193
        hdd_1969 = HardDrive(size=476940)
        hdd_1969.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))
        ram1 = RamModule(size=4096, speed=1600)
        ram2 = RamModule(size=2048, speed=1067)
        cpu = Processor(cores=2, speed=3.4)
        cpu.events_one.add(BenchmarkProcessor(rate=27136.44))
        pc_1193.components.add(hdd_1969, ram1, ram2, cpu)
        # add functionality and appearance range
        rate_pc_1193 = WorkbenchRate(appearance_range=AppearanceRange.A, functionality_range=FunctionalityRange.A)
        # add component rate
        HDD_rate = 4.02
        RAM_rate = 3.79
        Processor_rate = 3.95
        Rating = 4.61

        pc_1201 = Computer()
        price = 69.6
        hdd_3054 = HardDrive(size=476940)
        hdd_3054.events_one.add(BenchmarkDataStorage(read_speed=158, write_speed=34.7))
        ram1 = RamModule(size=2048, speed=1333)
        cpu = Processor(cores=2, speed=3.3)
        cpu.events_one.add(BenchmarkProcessor(rate=26339.48))
        pc_1201.components.add(hdd_3054, ram1, cpu)
        # add functionality and appearance range
        rate_pc_1201 = WorkbenchRate(appearance_range=AppearanceRange.B, functionality_range=FunctionalityRange.A)
        # add component rate
        HDD_rate = 4.07
        RAM_rate = 2.02
        Processor_rate = 3.93
        Rating = 3.48

        pc_79 = Computer()
        price = VeryLow
        hdd_81 = HardDrive(size=76319)
        hdd_81.events_one.add(BenchmarkDataStorage(read_speed=72.2, write_speed=24.3))
        ram1 = RamModule(size=512, speed=667)
        ram2 = RamModule(size=512, speed=800)
        ram3 = RamModule(size=512, speed=667)
        ram4 = RamModule(size=512, speed=533)
        cpu = Processor(cores=1, speed=1.6)
        cpu.events_one.add(BenchmarkProcessor(rate=3192.34))
        pc_79.components.add(hdd_81, ram1, ram2, ram3, ram4, cpu)
        # add functionality and appearance range
        rate_pc_79 = WorkbenchRate(appearance_range=AppearanceRange.C, functionality_range=FunctionalityRange.A)
        # add component rate
        HDD_rate = 2.61
        RAM_rate = 1.99
        Processor_rate = 1
        Rating = 1.58

        pc_798 = Computer()
        price = 50
        hdd_1556 = HardDrive(size=152587)
        hdd_1556.events_one.add(BenchmarkDataStorage(read_speed=78.1, write_speed=24.4))
        ram0 = RamModule(size=0, speed=None)
        cpu = Processor(cores=2, speed=2.5)
        cpu.events_one.add(BenchmarkProcessor(rate=9974.3))
        pc_798.components.add(hdd_1556, ram0, cpu)
        # add functionality and appearance range
        rate_pc_798 = WorkbenchRate(appearance_range=AppearanceRange.B, functionality_range=FunctionalityRange.A)
        # add component rate
        HDD_rate = 3.7
        RAM_rate = 1
        Processor_rate = 4.09
        Rating = 2.5
    """

    # Create a new Computer with components characteristics of pc with id = 1193
    pc_test = Desktop(chassis=ComputerChassis.Tower)
    data_storage = HardDrive(size=476940)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=126, write_speed=29.8))
    cpu = Processor(cores=2, speed=3.4)
    cpu.events_one.add(BenchmarkProcessor(rate=27136.44))
    pc_test.components |= {
        data_storage,
        RamModule(size=4096, speed=1600),
        RamModule(size=2048, speed=1067),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.A,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert math.isclose(rate_pc.ram, 3.79, rel_tol=0.001)

    assert math.isclose(rate_pc.data_storage, 4.02, rel_tol=0.001)

    assert math.isclose(rate_pc.processor, 3.95, rel_tol=0.001)

    assert math.isclose(rate_pc.rating, 4.61, rel_tol=0.001)

    # Create a new Computer with components characteristics of pc with id = 1201
    pc_test = Desktop(chassis=ComputerChassis.Tower)
    data_storage = HardDrive(size=476940)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=158, write_speed=34.7))
    cpu = Processor(cores=2, speed=3.3)
    cpu.events_one.add(BenchmarkProcessor(rate=26339.48))
    pc_test.components |= {
        data_storage,
        RamModule(size=2048, speed=1333),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.B,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert math.isclose(rate_pc.ram, 2.02, rel_tol=0.001)

    assert math.isclose(rate_pc.data_storage, 4.07, rel_tol=0.001)

    assert math.isclose(rate_pc.processor, 3.93, rel_tol=0.001)

    assert math.isclose(rate_pc.rating, 3.48, rel_tol=0.001)

    # Create a new Computer with components characteristics of pc with id = 79
    pc_test = Desktop(chassis=ComputerChassis.Tower)
    data_storage = HardDrive(size=76319)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=72.2, write_speed=24.3))
    cpu = Processor(cores=1, speed=1.6)
    cpu.events_one.add(BenchmarkProcessor(rate=3192.34))
    pc_test.components |= {
        data_storage,
        RamModule(size=512, speed=667),
        RamModule(size=512, speed=800),
        RamModule(size=512, speed=667),
        RamModule(size=512, speed=533),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.C,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert math.isclose(rate_pc.ram, 1.99, rel_tol=0.001)

    assert math.isclose(rate_pc.data_storage, 2.61, rel_tol=0.001)

    assert math.isclose(rate_pc.processor, 1, rel_tol=0.001)

    assert math.isclose(rate_pc.rating, 1.58, rel_tol=0.001)

    # Create a new Computer with components characteristics of pc with id = 798
    pc_test = Desktop(chassis=ComputerChassis.Tower)
    data_storage = HardDrive(size=152587)
    data_storage.events_one.add(BenchmarkDataStorage(read_speed=78.1, write_speed=24.4))
    cpu = Processor(cores=2, speed=2.5)
    cpu.events_one.add(BenchmarkProcessor(rate=9974.3))
    pc_test.components |= {
        data_storage,
        RamModule(size=0, speed=None),
        cpu
    }
    # add functionality and appearance range
    rate_pc = WorkbenchRate(appearance_range=AppearanceRange.B,
                            functionality_range=FunctionalityRange.A)
    # Compute all components rates and general rating
    Rate().compute(pc_test, rate_pc)

    assert math.isclose(rate_pc.ram, 1, rel_tol=0.001)

    assert math.isclose(rate_pc.data_storage, 3.7, rel_tol=0.001)

    assert math.isclose(rate_pc.processor, 4.09, rel_tol=0.001)

    assert math.isclose(rate_pc.rating, 2.5, rel_tol=0.001)