def test__check_compatible__not_existing(self, cee_patch): elements = mock.MagicMock() cee_patch.return_value = False, mock.MagicMock() expected_result = cee_patch() actual_result = game_content.check_compatible(elements) self.assertEqual(expected_result, actual_result) cee_patch.assert_called_with(elements)
def build(data: dict, user: str) -> dict: """ This endpoint you can test your build if the parts a compatible and what is required for a device """ comp, message = check_compatible(data) if not comp: return message performance: tuple = calculate_power(data) return_message: dict = {"success": True, "performance": performance} return return_message
def test__check_compatible__incompatible_ram_frequency(self, cee_patch): elements = { "cpu": ["cpu1"], "mainboard": "mainboard1", "gpu": ["gpu1"], "disk": ["disk1", "disk2"], "ram": ["ram1"], "processorCooler": ["cooler1"], "powerPack": None, "case": "case1", } cee_patch.return_value = True, {} expected_result = False, {"error": "incompatible_ram_frequency"} actual_result = game_content.check_compatible(elements) self.assertEqual(expected_result, actual_result) cee_patch.assert_called_with(elements)
def test__check_compatible__missing_cpu(self, cee_patch): elements = { "cpu": [], "mainboard": None, "gpu": [], "disk": [], "ram": [], "processorCooler": [], "powerPack": None, "case": None, } cee_patch.return_value = True, {} expected_result = False, {"error": "missing_cpu"} actual_result = game_content.check_compatible(elements) self.assertEqual(expected_result, actual_result) cee_patch.assert_called_with(elements)
def create_device(data: dict, user: str) -> dict: """ Create a device. :param data: The given data. :param user: The user uuid. :return: The response """ count: int = wrapper.session.query(func.count( Device.uuid)).filter_by(owner=user).scalar() if count >= 3: return maximum_devices_reached comp, message = check_compatible(data) if not comp: return message comp, message = check_exists(user, data) if not comp: return message performance: tuple = calculate_power(data) device: Device = Device.create(user, True) Workload.create(device.uuid, performance) create_hardware(data, device.uuid) delete_items(user, data) m.contact_microservice("service", ["device_init"], { "device_uuid": device.uuid, "user": device.owner }) return device.serialize
def test__start_pc_compatible(self): self.assertEqual((True, {}), check_compatible(hardware["start_pc"]))