| Total Complexity | 3 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from graphinate.color import color_hex |
||
| 4 | |||
| 5 | colors = [ |
||
| 6 | ([0, 0, 0], "#000000"), |
||
| 7 | ([0.5, 0.5, 0.5], "#7f7f7f"), |
||
| 8 | ([1, 1, 1], "#010101"), |
||
| 9 | ([2, 2, 2], "#020202"), |
||
| 10 | ([50, 50, 50], "#323232"), |
||
| 11 | ([100, 100, 100], "#646464"), |
||
| 12 | ([128, 128, 128], "#808080"), |
||
| 13 | ([255, 255, 255], "#ffffff"), |
||
| 14 | ("Not a Sequence", "Not a Sequence") |
||
| 15 | ] |
||
| 16 | |||
| 17 | |||
| 18 | @pytest.mark.parametrize(('color', 'expected_color_hex'), colors) |
||
| 19 | def test_color_hex(color, expected_color_hex): |
||
| 20 | # act |
||
| 21 | actual_color_hex = color_hex(color) |
||
| 22 | |||
| 23 | # assert |
||
| 24 | assert actual_color_hex == expected_color_hex |
||
| 25 | |||
| 26 | |||
| 27 | def test_color_hex_error(): |
||
| 28 | with pytest.raises(ValueError, |
||
| 29 | match="Input values should either be a float between 0 and 1 or an int between 0 and 255"): |
||
| 30 | _ = color_hex(["a", "b", "c"]) |
||
| 31 |