GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 14b837...27d348 )
by thatsIch
01:03
created

IntToHexTest.test_default()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
1
"""Test color converter."""
2
3
4
import sys
5
6
from unittest import TestCase
7
8
COLOR_CONVERTER = sys.modules["Rainmeter.color.converter"]
9
10
11
class IntToHexTest(TestCase):
12
    """Testing int to hex conversion and its corner cases."""
13
14
    def test_below_lower_boundary(self):
15
        """Rainmeter only supports from 0 upwards."""
16
        self.assertRaises(AssertionError, COLOR_CONVERTER.int_to_hex, -1)
17
18
    def test_lower_boundary(self):
19
        """Zero is a corner case and should return 00."""
20
        hex_value = COLOR_CONVERTER.int_to_hex(0)
21
22
        self.assertEqual(hex_value, "00")
23
24
    def test_default(self):
25
        """A random number within the boundary 0, 255 should work."""
26
        hex_value = COLOR_CONVERTER.int_to_hex(128)
27
28
        self.assertEqual(hex_value, "80")
29
30
    def test_upper_boundary(self):
31
        """255 is a corner case and should return FF."""
32
        hex_value = COLOR_CONVERTER.int_to_hex(255)
33
34
        self.assertEqual(hex_value, "FF")
35
36
    def test_over_upper_boundary(self):
37
        """Rainmeter only supports up to 255."""
38
        self.assertRaises(AssertionError, COLOR_CONVERTER.int_to_hex, 256)
39
40
    def test_letter_case(self):
41
        """We also support lower case if it is requested."""
42
        hex_value = COLOR_CONVERTER.int_to_hex(255, letter_case=COLOR_CONVERTER.LetterCase.Lower)
43
44
        self.assertEqual(hex_value, "ff")
45
46
47 View Code Duplication
class RGBsToHexesTest(TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
48
    """Testing RGBs to hexes conversion and its corner cases."""
49
50
    def test_default_rgb_conversion(self):
51
        """3 valid ints should convert to 3 hexes."""
52
        hexes = COLOR_CONVERTER.rgbs_to_hexes([128, 128, 128])
53
54
        self.assertEqual(hexes, ["80", "80", "80"])
55
56
    def test_default_rgba_conversion(self):
57
        """4 valid ints should convert to 4 hexes."""
58
        hexes = COLOR_CONVERTER.rgbs_to_hexes([128, 128, 128, 128])
59
60
        self.assertEqual(hexes, ["80", "80", "80", "80"])
61
62
63
    def test_invalid_rgb_low_len(self):
64
        """RGB are at least 3 values."""
65
        self.assertRaises(AssertionError, COLOR_CONVERTER.rgbs_to_hexes, [128, 128])
66
67
    def test_invalid_rgb_high_len(self):
68
        """RGB are at most 4 values."""
69
        self.assertRaises(AssertionError, COLOR_CONVERTER.rgbs_to_hexes, [128, 128, 128, 128, 128])
70
71
72
class HexesToStringTest(TestCase):
73
    """This test guerentees that a proper string conversion ."""
74
75
    def test_stringing(self):
76
        """Default case with one spacing."""
77
        stringed = COLOR_CONVERTER.hexes_to_string(["80", "80", "80"])
78
79
        self.assertEqual(stringed, "808080")
80
81
    def test_rgba(self):
82
        """RGBA case."""
83
        stringed = COLOR_CONVERTER.hexes_to_string(["80", "80", "80", "80"])
84
85
        self.assertEqual(stringed, "80808080")
86
87
88
class HexToIntTest(TestCase):
89
    """Testing hex to int conversion and its corner cases."""
90
91
    def test_below_lower_boundary(self):
92
        """Rainmeter only supports from 0 upwards."""
93
        self.assertRaises(AssertionError, COLOR_CONVERTER.hex_to_int, "-1")
94
95
    def test_lower_boundary(self):
96
        """00 is a corner case and should return 0."""
97
        int_value = COLOR_CONVERTER.hex_to_int("00")
98
99
        self.assertEqual(int_value, 0)
100
101
    def test_default(self):
102
        """A random number within the boundary 0, 255 should work."""
103
        int_value = COLOR_CONVERTER.hex_to_int("80")
104
105
        self.assertEqual(int_value, 128)
106
107
    def test_upper_boundary(self):
108
        """FF is a corner case and should return 255."""
109
        int_value = COLOR_CONVERTER.hex_to_int("FF")
110
111
        self.assertEqual(int_value, 255)
112
113
    def test_over_upper_boundary(self):
114
        """Rainmeter only supports up to 255."""
115
        self.assertRaises(AssertionError, COLOR_CONVERTER.hex_to_int, "100")
116
117
118 View Code Duplication
class HexesToRGBsTest(TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
119
    """Testing Hexes to RGBs conversion and its corner cases."""
120
121
    def test_default_hex_conversion(self):
122
        """."""
123
        rgb = COLOR_CONVERTER.hexes_to_rgbs(["80", "80", "80"])
124
125
        self.assertEqual(rgb, [128, 128, 128])
126
127
    def test_default_hexa_conversion(self):
128
        """4 valid hexes should convert to rgba."""
129
        rgba = COLOR_CONVERTER.hexes_to_rgbs(["80", "80", "80", "80"])
130
131
        self.assertEqual(rgba, [128, 128, 128, 128])
132
133
    def test_invalid_hex_low_len(self):
134
        """Require at least 3 values."""
135
        self.assertRaises(AssertionError, COLOR_CONVERTER.hexes_to_rgbs, ["FF", "FF"])
136
137
    def test_invalid_hex_high_len(self):
138
        """Require at most 4 values."""
139
        self.assertRaises(
140
            AssertionError,
141
            COLOR_CONVERTER.hexes_to_rgbs,
142
            ["FF", "FF", "FF", "FF", "FF"]
143
        )
144
145
146
class RGBsToStringTest(TestCase):
147
    """This test guerentees that a proper string conversion ."""
148
149
    def test_stringing(self):
150
        """Default Rainmeter decimal color representation."""
151
        stringed = COLOR_CONVERTER.rgbs_to_string([128, 128, 128])
152
153
        self.assertEqual(stringed, "128,128,128")
154
155
    def test_with_spacing(self):
156
        """For people who like to space things."""
157
        stringed = COLOR_CONVERTER.rgbs_to_string([128, 128, 128], spacing=1)
158
159
        self.assertEqual(stringed, "128, 128, 128")
160
161
    def test_with_more_spacing(self):
162
        """For people who like to use a lot of spacings."""
163
        stringed = COLOR_CONVERTER.rgbs_to_string([128, 128, 128], spacing=5)
164
165
        self.assertEqual(stringed, "128,     128,     128")
166