예제 #1
0
 def setUp(self):
     self.mock_hid = _MockKrakenDevice(raw_led_channels=0)
     self.device = KrakenZ3(self.mock_hid,
                            'Mock Kraken Z73',
                            speed_channels=_SPEED_CHANNELS_KRAKENZ,
                            color_channels={})
     self.device.connect()
예제 #2
0
    def __init__(self, dbus_interface, configMgr):
        # find the Kraken
        supported_devices = KrakenZ3.find_supported_devices()

        if not supported_devices:
            supported_devices = KrakenX3.find_supported_devices()

        if not supported_devices:
            supported_devices = KrakenTwoDriver.find_supported_devices()

        if not supported_devices:
            raise Exception('Failed to find the Kraken X')

        print("Found device: ", supported_devices[0].description)
        self.kraken_device = supported_devices[0]

        self.configMgr = configMgr
        dbus_interface.KrakenDevice = supported_devices[0].description

        # The last update to the speeds
        self.last_update = 0
        self.last_temp = {'cpu': 0, 'liquid': 0}
        self.last_speed_set = {'fan': 0, 'pump': 0}
        self.dbus_interface = dbus_interface
        self.boost_start = 0
        self.dbus_interface.controller = self
        self.was_boosting = False
예제 #3
0
def mockKrakenZDevice():
    device = _MockKrakenDevice(raw_led_channels=0)
    dev = KrakenZ3(device, 'Mock Kraken Z73',
                   speed_channels=_SPEED_CHANNELS_KRAKENZ,
                   color_channels={})

    dev.connect()
    return dev
예제 #4
0
def mock_krakenz3():
    raw = MockKraken(raw_led_channels=1)
    dev = KrakenZ3(
        raw,
        "Mock Kraken Z73",
        speed_channels=_SPEED_CHANNELS_KRAKENZ,
        color_channels=_COLOR_CHANNELS_KRAKENZ,
    )

    dev.connect()
    return dev
예제 #5
0
파일: test_di.py 프로젝트: leinardi/gkraken
 def test_driver_multiple(self, mocker: MockerFixture) -> None:
     # arrange
     mocker.patch.object(
         DeviceSettings,
         '__subclasses__',
         return_value=[SettingsKrakenZ3, SettingsKrakenX3, SettingsKraken2])
     mocker.patch.object(Kraken2,
                         'find_supported_devices',
                         return_value=[Kraken2('01234', 'test device')])
     mocker.patch.object(
         KrakenX3,
         'find_supported_devices',
         return_value=[KrakenX3('01234', 'test device', [], [])])
     mocker.patch.object(KrakenZ3,
                         'find_supported_devices',
                         return_value=[
                             KrakenZ3('01234', 'test device 1', [], []),
                             KrakenZ3('01234', 'test device 2', [], []),
                         ])
     # act
     driver = INJECTOR.get(Optional[BaseDriver])
     # assert should take the first found device from the first driver in the list of supported_drivers
     assert isinstance(driver, KrakenZ3)
     assert driver.description == 'test device 1'
예제 #6
0
파일: test_di.py 프로젝트: leinardi/gkraken
 def test_driver_x_vs_z(self, mocker: MockerFixture) -> None:
     # arrange
     mocker.patch.object(DeviceSettings,
                         '__subclasses__',
                         return_value=[SettingsKrakenX3, SettingsKrakenZ3])
     mocker.patch.object(KrakenX3,
                         'find_supported_devices',
                         return_value=[])
     mocker.patch.object(KrakenZ3,
                         'find_supported_devices',
                         return_value=[
                             KrakenZ3('01234', 'test device z', [], []),
                         ])
     # act
     driver = INJECTOR.get(Optional[BaseDriver])
     # assert even though the z driver is a subclass of the x driver, that it correctly pulls the right one
     assert isinstance(driver, KrakenZ3)
     assert isinstance(driver, KrakenX3)
     assert KrakenZ3 is driver.__class__
     assert KrakenX3 is not driver.__class__