def testLatimesIpsum(self): from greeking import latimes_ipsum story = latimes_ipsum.get_story() self.assertTrue(isinstance(story, latimes_ipsum.Story)) self.assertTrue(isinstance(story.content, six.string_types)) related_items = latimes_ipsum.get_related_items() self.assertTrue(isinstance(related_items[0], latimes_ipsum.RelatedItem)) self.assertTrue(len(related_items) == 4) self.assertTrue(len(latimes_ipsum.get_related_items(1)) == 1) image = latimes_ipsum.get_image(250) self.assertTrue(isinstance(image, latimes_ipsum.Image)) t2 = latimes_ipsum.get_image(250, 250, True) ctx, out = self.render(t2) self.assertTrue( t2.url != 'http://placehold.it/250x250/cccccc/969696/' ) t3 = latimes_ipsum.get_image(250) ctx, out = self.render(t3) self.assertTrue( t3.url == 'http://placehold.it/250x250/cccccc/969696/' ) quote = latimes_ipsum.get_quote() self.assertTrue(isinstance(quote, latimes_ipsum.Quote)) """ Tests the tags for pulling story, image, related items, and quotes """ t4 = "{% load greeking_tags %}{% latimes_story as obj %}" ctx, out = self.render(t4) t5 = "{% load greeking_tags %}{% latimes_image 250 250 000000 as obj %} \ {{ obj.url }} \ {{ obj.caption }} \ {{ obj.credit }}" ctx, out = self.render(t5) t6 = "{% load greeking_tags %}{% latimes_quote as obj %} \ {{ obj.quote }} \ {{ obj.source }}" ctx, out = self.render(t6) t7 = "{% load greeking_tags %}{% latimes_related_items as obj %} \ {{ obj.headline }} \ {{ obj.url }} \ {{ obj.image_url }}" ctx, out = self.render(t7) t8 = "{% load greeking_tags %}{% latimes_related_items 1 as obj %}" ctx, out = self.render(t8)
def latimes_image(width, height, background_color): """ Return an latimes_ipsum Image object with a default background color of #ccc unless you specify a background color. Also has option to return caption and credit. Usage format: {% latimes_image [width] [height] [background_color] as obj %} Example usage: Image at 250 wide and 400 high with background color of #000 {% latimes_image 250 400 000000 %} <img src="{{obj.url}}"> {{ obj.caption }} {{ obj.credit }} """ return get_image(width, height, background_color)