# Path: pytrainer/util/color.py
# class Color(object):
#     
#     """A color represented as a 24-bit RGB value."""
#     
#     def __init__(self, rgb_val=0):
#         rgb_val_int = int(rgb_val)
#         if rgb_val_int < 0:
#             raise ValueError("RGB value must not be negative.")
#         if rgb_val_int > 0xffffff:
#             raise ValueError("RGB value must not be greater than 0xffffff.")
#         self._rgb_val = rgb_val_int
#         
#     def _get_rgb_val(self):
#         return self._rgb_val
#     
#     rgb_val = property(_get_rgb_val)
#         
#     def _get_rgba_val(self):
#         return self._rgb_val << 8
#     
#     rgba_val = property(_get_rgba_val)
#     
#     def to_hex_string(self):
#         return "{0:06x}".format(self._rgb_val)
# 
# def color_from_hex_string(hex_string):
#     return Color(int(hex_string, 16))


from pytrainer.util.color import Color, color_from_hex_string
import unittest
    def test_constructor_should_not_accept_value_over_24_bit(self):
        try:
            Color(2 ** 24)
        except(ValueError):
            pass
        else:
            self.fail()

    def test_rgb_value_should_default_to_0(self):
        color = Color()
        self.assertEqual(0, color.rgb_val)
            
    def test_rgb_value_should_be_read_only(self):
        color = Color()
        try:
            color.rgb_val = 1
        except(AttributeError):
            pass
        else:
            self.fail()
            
    def test_rgba_value_should_be_rgb_value_with_two_trailing_zero_hex_digits(self):
        color = Color(0x1177ff)
        self.assertEqual(0x1177ff00, color.rgba_val)
        
    def test_to_hex_string_should_create_six_digit_hex_value(self):
        color = Color(0xfab)
        self.assertEqual("000fab", color.to_hex_string())
        
    def test_color_from_hex_string_should_correctly_decode_hex_value(self):

# Path: pytrainer/util/color.py
# class Color(object):
#     
#     """A color represented as a 24-bit RGB value."""
#     
#     def __init__(self, rgb_val=0):
#         rgb_val_int = int(rgb_val)
#         if rgb_val_int < 0:
#             raise ValueError("RGB value must not be negative.")
#         if rgb_val_int > 0xffffff:
#             raise ValueError("RGB value must not be greater than 0xffffff.")
#         self._rgb_val = rgb_val_int
#         
#     def _get_rgb_val(self):
#         return self._rgb_val
#     
#     rgb_val = property(_get_rgb_val)
#         
#     def _get_rgba_val(self):
#         return self._rgb_val << 8
#     
#     rgba_val = property(_get_rgba_val)
#     
#     def to_hex_string(self):
#         return "{0:06x}".format(self._rgb_val)
# 
# def color_from_hex_string(hex_string):
#     return Color(int(hex_string, 16))


# Path: pytrainer/test/util/test_color.py
from pytrainer.util.color import Color, color_from_hex_string
import unittest

    def test_constructor_should_not_accept_value_over_24_bit(self):
        try:
            Color(2 ** 24)
        except(ValueError):
            pass
        else:
            self.fail()

    def test_rgb_value_should_default_to_0(self):
        color = Color()
        self.assertEqual(0, color.rgb_val)
            
    def test_rgb_value_should_be_read_only(self):
        color = Color()
        try:
            color.rgb_val = 1
        except(AttributeError):
            pass
        else:
            self.fail()
            
    def test_rgba_value_should_be_rgb_value_with_two_trailing_zero_hex_digits(self):
        color = Color(0x1177ff)
        self.assertEqual(0x1177ff00, color.rgba_val)
        
    def test_to_hex_string_should_create_six_digit_hex_value(self):
        color = Color(0xfab)
        self.assertEqual("000fab", color.to_hex_string())
        
    def test_color_from_hex_string_should_correctly_decode_hex_value(self):

        color = color_from_hex_string("fab")