-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from dodona-edu/colour
added color conversions + tests
- Loading branch information
Showing
6 changed files
with
102 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import unittest | ||
from utils.color_converter import Color | ||
|
||
|
||
class TestColorConverter(unittest.TestCase): | ||
|
||
def test_conversion_red(self): | ||
correct = Color("red") | ||
|
||
# All possibilities to make the color "red" | ||
self.assertEqual(correct, Color("red"), "test name") | ||
|
||
self.assertEqual(correct, Color("#ff0000"), "test hex") | ||
self.assertEqual(correct, Color("#ff0000ff"), "test hex") | ||
self.assertEqual(correct, Color("#f00"), "test hex") | ||
self.assertEqual(correct, Color("#f00f"), "test hex") | ||
|
||
self.assertEqual(correct, Color("rgb(255,0,0)"), "test rgb") | ||
self.assertEqual(correct, Color("rgb(100%,0,0)"), "test rgb") | ||
|
||
self.assertEqual(correct, Color("rgba(255,0,0,1)"), "test rgba") | ||
self.assertEqual(correct, Color("rgba(100%,0%,0%,1)"), "test rgba") | ||
|
||
self.assertEqual(correct, Color("hsl(0, 100%, 50%)"), "test hsl") | ||
|
||
self.assertEqual(correct, Color("hsla(0, 100%, 50%,1)"), "test hsla") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.