コード例 #1
0
 def test_rgb_dict_object_to_rgb_dict(self):
     """
     Creates colours using a dictionary, and calls `rgb_dict`, validating the output
     """
     for hex_code, rgb_dict in SAMPLE_HAPPY_COLOURS.items():
         c = rgb.Colour(rgb_dict=rgb_dict)
         assert c.to_rgb_dict() == rgb_dict
コード例 #2
0
 def test_instantiate_by_dict(self):
     """
     Can we instantiate a Colour class with a dictionary as input? No Validation
     """
     for hex_code, rgb_dict in SAMPLE_HAPPY_COLOURS.items():
         c = rgb.Colour(rgb_dict=rgb_dict)
         assert type(c) == rgb.Colour
コード例 #3
0
 def test_instantiate_by_hex(self):
     """
     Can we instantiate a Colour class with a 6 digit hex code as input? No Validation
     """
     for hex_code, rgb_dict in SAMPLE_HAPPY_COLOURS.items():
         c = rgb.Colour(hex_code=hex_code)
         assert type(c) == rgb.Colour
コード例 #4
0
 def test_rgb_dict_object_to_hex_code(self):
     """
     Creates Colours using rgb_dicts, then validates that the `to_hex_code` method returns the right value
     """
     for hex_code, rgb_dict in SAMPLE_HAPPY_COLOURS.items():
         c = rgb.Colour(rgb_dict=rgb_dict)
         # Note the test here calls `lower` because we don't have a perference for if the output is upper or lower
         assert c.to_hex_code().lower() == hex_code.lower()