Example #1
0
 def setUp(self):
     self.mock_hid = MockHidapiDevice()
     self.device = SmartDevice(self.mock_hid,
                               'Mock Smart Device',
                               speed_channel_count=3,
                               color_channel_count=1)
     self.device.connect()
def test_smart_device_v1_backwards_modes_are_deprecated(caplog):
    modes = [
        'backwards-spectrum-wave', 'backwards-marquee-3',
        'backwards-marquee-4', 'backwards-marquee-5', 'backwards-marquee-6',
        'covering-backwards-marquee', 'backwards-moving-alternating',
        'backwards-super-wave'
    ]

    from liquidctl.driver.smart_device import SmartDevice

    for mode in modes:
        base_mode = mode.replace('backwards-', '')

        old = SmartDevice(MockHidapiDevice(),
                          'Mock Smart Device',
                          speed_channel_count=3,
                          color_channel_count=1)
        new = SmartDevice(MockHidapiDevice(),
                          'Mock Smart Device',
                          speed_channel_count=3,
                          color_channel_count=1)

        colors = [RADICAL_RED, MOUNTAIN_MEADOW]

        old.set_color('led', mode, colors)
        new.set_color('led', base_mode, colors, direction='backward')

        assert old.device.sent == new.device.sent, \
               f'{mode} != {base_mode} + direction=backward'

        assert 'deprecated mode' in caplog.text
Example #3
0
def mockSmartDevice():
    device = MockHidapiDevice(vendor_id=0x1e71,
                              product_id=0x1714,
                              address='addr')
    return SmartDevice(device,
                       'mock NZXT Smart Device V1',
                       speed_channel_count=3,
                       color_channel_count=1)
Example #4
0
class SmartDeviceTestCase(unittest.TestCase):
    def setUp(self):
        self.mock_hid = MockHidapiDevice()
        self.device = SmartDevice(self.mock_hid,
                                  'Mock Smart Device',
                                  speed_channel_count=3,
                                  color_channel_count=1)
        self.device.connect()

    def tearDown(self):
        self.device.disconnect()

    def test_not_totally_broken(self):
        """A few reasonable example calls do not raise exceptions."""
        for i in range(3):
            self.mock_hid.preload_read(Report(0, bytes(63)))
        self.device.initialize()
        status = self.device.get_status()
        self.device.set_color(channel='led',
                              mode='breathing',
                              colors=iter([[142, 24, 68]]),
                              speed='fastest')
        self.device.set_fixed_speed(channel='fan3', duty=50)