File: test_backward_compatibility_14.py

package info (click to toggle)
liquidctl 1.16.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,452 kB
  • sloc: python: 15,304; sh: 712; xml: 84; makefile: 4
file content (132 lines) | stat: -rw-r--r-- 5,291 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
"""Test backward compatibility with liquidctl 1.4.x."""

import pytest
from _testutils import MockHidapiDevice

RADICAL_RED = [0xff, 0x35, 0x5e]
MOUNTAIN_MEADOW = [0x1a, 0xb3, 0x85]


def test_find_from_driver_package_still_available():
    from liquidctl.driver import find_liquidctl_devices


def test_kraken2_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.kraken2 import Kraken2

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

        old = Kraken2(MockHidapiDevice(), 'Mock X62',
                      device_type=Kraken2.DEVICE_KRAKENX)
        new = Kraken2(MockHidapiDevice(), 'Mock X62',
                      device_type=Kraken2.DEVICE_KRAKENX)

        colors = [RADICAL_RED, MOUNTAIN_MEADOW]

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

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

        assert 'deprecated mode' in caplog.text


def test_kraken3_backwards_modes_are_deprecated(caplog):
    modes = ['backwards-spectrum-wave', 'backwards-marquee-3',
             'backwards-marquee-4', 'backwards-marquee-5',
             'backwards-marquee-6', 'backwards-moving-alternating-3',
             'covering-backwards-marquee', 'backwards-moving-alternating-4',
             'backwards-moving-alternating-5', 'backwards-moving-alternating-6',
             'backwards-rainbow-flow', 'backwards-super-rainbow',
             'backwards-rainbow-pulse']

    from liquidctl.driver.kraken3 import KrakenX3
    from liquidctl.driver.kraken3 import _COLOR_CHANNELS_KRAKENX
    from liquidctl.driver.kraken3 import _SPEED_CHANNELS_KRAKENX
    from liquidctl.driver.kraken3 import _HWMON_CTRL_MAPPING_KRAKENX

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

        old = KrakenX3(MockHidapiDevice(), 'Mock X63',
                       speed_channels=_SPEED_CHANNELS_KRAKENX,
                       color_channels=_COLOR_CHANNELS_KRAKENX,
                       hwmon_ctrl_mapping=_HWMON_CTRL_MAPPING_KRAKENX)
        new = KrakenX3(MockHidapiDevice(), 'Mock X63',
                       speed_channels=_SPEED_CHANNELS_KRAKENX,
                       color_channels=_COLOR_CHANNELS_KRAKENX,
                       hwmon_ctrl_mapping=_HWMON_CTRL_MAPPING_KRAKENX)

        colors = [RADICAL_RED, MOUNTAIN_MEADOW]

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

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

        assert 'deprecated mode' in caplog.text


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


def test_hue2_backwards_modes_are_deprecated(caplog):
    modes = ['backwards-spectrum-wave', 'backwards-marquee-3',
             'backwards-marquee-4', 'backwards-marquee-5',
             'backwards-marquee-6', 'backwards-moving-alternating-3',
             'covering-backwards-marquee', 'backwards-moving-alternating-4',
             'backwards-moving-alternating-5', 'backwards-moving-alternating-6',
             'backwards-rainbow-flow', 'backwards-super-rainbow',
             'backwards-rainbow-pulse']

    from liquidctl.driver.smart_device import SmartDevice2

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

        old = SmartDevice2(MockHidapiDevice(), 'Mock Smart Device V2',
                           speed_channel_count=3, color_channel_count=2)
        new = SmartDevice2(MockHidapiDevice(), 'Mock Smart Device V2',
                           speed_channel_count=3, color_channel_count=2)

        colors = [RADICAL_RED, MOUNTAIN_MEADOW]

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

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

        assert 'deprecated mode' in caplog.text