def test_rgb_value_should_be_read_only(self): color = Color() try: color.rgb_val = 1 except (AttributeError): pass else: self.fail()
def test_rgb_value_should_be_read_only(self): color = Color() try: color.rgb_val = 1 except(AttributeError): pass else: self.fail()
def __init__(self): self._id = None self.name = u"" self.weight = 0.0 self.met = None self.max_pace = None self.color = Color(0x0000ff)
def test_constructor_should_not_accept_negative_value(self): try: Color(-1) except (ValueError): pass else: self.fail()
def test_constructor_should_not_accept_value_over_24_bit(self): try: Color(2**24) except (ValueError): pass else: self.fail()
def test_constructor_should_not_accept_none(self): try: Color(None) except (TypeError): pass else: self.fail()
def test_constructor_should_not_accept_non_integer_string(self): try: Color("ff00ff") except (ValueError): pass else: self.fail()
def convert_to_color(self, gdk_col): """Convert a GDK color to a Pytrainer color.""" red = gdk_col.red >> 8 green = gdk_col.green >> 8 blue = gdk_col.blue >> 8 rgb_val = (red << 16) + (green << 8) + blue return Color(rgb_val)
def test_convert_to_gdk_color_should_create_gdk_color_with_equivalent_rgb_values( self): color = Color(0xaaff33) gdk_color = self._converter.convert_to_gdk_color(color) self.assertEquals(0x3333, gdk_color.blue) self.assertEquals(0xffff, gdk_color.green) self.assertEquals(0xaaaa, gdk_color.red)
def test_to_hex_string_should_create_six_digit_hex_value(self): color = Color(0xfab) self.assertEquals("000fab", color.to_hex_string())
def test_rgba_value_should_be_rgb_value_with_two_trailing_zero_hex_digits( self): color = Color(0x1177ff) self.assertEquals(0x1177ff00, color.rgba_val)
def test_rgb_value_should_default_to_0(self): color = Color() self.assertEqual(0, color.rgb_val)
def test_constructor_should_accept_integer_string(self): color = Color("12345") self.assertEqual(12345, color.rgb_val)