@@ 47-69 (lines=23) @@ | ||
44 | self.assertEqual(hex_value, "ff") |
|
45 | ||
46 | ||
47 | class RGBsToHexesTest(TestCase): |
|
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 | def test_invalid_rgb_low_len(self): |
|
63 | """RGB are at least 3 values.""" |
|
64 | self.assertRaises(AssertionError, COLOR_CONVERTER.rgbs_to_hexes, [128, 128]) |
|
65 | ||
66 | def test_invalid_rgb_high_len(self): |
|
67 | """RGB are at most 4 values.""" |
|
68 | self.assertRaises(AssertionError, COLOR_CONVERTER.rgbs_to_hexes, [128, 128, 128, 128, 128]) |
|
69 | ||
70 | ||
71 | class HexesToStringTest(TestCase): |
|
72 | """This test guerentees that a proper string conversion .""" |
|
@@ 117-141 (lines=25) @@ | ||
114 | self.assertRaises(AssertionError, COLOR_CONVERTER.hex_to_int, "100") |
|
115 | ||
116 | ||
117 | class HexesToRGBsTest(TestCase): |
|
118 | """Testing Hexes to RGBs conversion and its corner cases.""" |
|
119 | ||
120 | def test_default_hex_conversion(self): |
|
121 | """.""" |
|
122 | rgb = COLOR_CONVERTER.hexes_to_rgbs(["80", "80", "80"]) |
|
123 | ||
124 | self.assertEqual(rgb, [128, 128, 128]) |
|
125 | ||
126 | def test_default_hexa_conversion(self): |
|
127 | """4 valid hexes should convert to rgba.""" |
|
128 | rgba = COLOR_CONVERTER.hexes_to_rgbs(["80", "80", "80", "80"]) |
|
129 | ||
130 | self.assertEqual(rgba, [128, 128, 128, 128]) |
|
131 | ||
132 | def test_invalid_hex_low_len(self): |
|
133 | """Require at least 3 values.""" |
|
134 | self.assertRaises(AssertionError, COLOR_CONVERTER.hexes_to_rgbs, ["FF", "FF"]) |
|
135 | ||
136 | def test_invalid_hex_high_len(self): |
|
137 | """Require at most 4 values.""" |
|
138 | self.assertRaises( |
|
139 | AssertionError, |
|
140 | COLOR_CONVERTER.hexes_to_rgbs, |
|
141 | ["FF", "FF", "FF", "FF", "FF"] |
|
142 | ) |
|
143 | ||
144 |