def test_should_return_arbitrarily_nested_components(self):
        """
        Should return components nested more than
        one layer deep
        """
        subject = ComponentCollection()
        widget = Component()
        widget.name = "widget"
        doodad = Component()
        doodad.name = "doodad"
        whatsit = Component()
        whatsit.name = "whatsit"
        widget.components.append(doodad)
        doodad.components.append(whatsit)
        subject.append(widget)

        self.assertIn(whatsit, subject.recursively_collect_components())
Esempio n. 2
0
 def draw_high_low(self):
     """ Draw high/low today's temperatures """
     
     bb_x = self.temp_right_edge
     bb_y = int((self.rect.h / 100) * TOP_HEIGHT)
     bb_w = self.rect.w - bb_x
     bb_h = self.rect.h - bb_y - int((self.rect.h / 100) * BOTTOM_HEIGHT)
     text_color = self.util.weather_config[COLOR_CONTRAST]
     font_size = int((bb_w / 100) * HIGH_LOW_TEXT_SIZE)
     
     c = self.util.get_text_component(self.high, text_color, font_size)
     w = c.content.get_size()[0]
     h = c.content.get_size()[1]
     c.content_x = bb_x + int((bb_w - w) / 2)
     c.content_y = bb_y + int((bb_h - h) / 2) - (font_size / 2)
     self.add_component(c)
     
     c = self.util.get_text_component(self.low, text_color, font_size)
     w = c.content.get_size()[0]
     h = c.content.get_size()[1]
     c.content_x = bb_x + int((bb_w - w) / 2)
     c.content_y = bb_y + int((bb_h - h) / 2) + (font_size / 1.4)
     self.add_component(c)
     
     x = c.content_x
     y = bb_y + int(bb_h / 2)
     w = c.content.get_size()[0]
     h = 2
     r = pygame.Rect(x, y, w, h)
     c = Component(self.util, r)
     c.name = "sep" + ".text"
     c.content_x = 0
     c.content_y = 0
     c.fgr = text_color
     c.bgr = text_color
     self.add_component(c)