def test_blogpost_with_first_image_as_thumbnail_as_src_set( self, blogpost, tpl): title = faker.sentence() post_url = faker.uri() image_url = faker.image_url() summary = faker.sentence() tz = pytz.timezone(faker.timezone()) publish_date = faker.date_time(tzinfo=tz) srcset = ', '.join(' '.join((faker.image_url(width=w), '{0}w'.format(w))) for w in ('1200', '1024', '300')) sizes = "(max-width: 1200px) 100vw, 1200px" content = tpl.format(image_url, srcset, sizes) feed = self.feed('Some blog', title, content, post_url, published=publish_date, summary=summary) post = blogpost(feed) assert post['title'] == title assert post['link'] == post_url assert post['summary'] == summary assert_equal_dates(post['date'], publish_date) assert post['image_url'] == image_url assert post['srcset'] == srcset assert post['sizes'] == sizes
def test_blogpost_with_first_image_as_thumbnail_as_src_set(self, blogpost, tpl): title = faker.sentence() post_url = faker.uri() image_url = faker.image_url() summary = faker.sentence() tz = pytz.timezone(faker.timezone()) publish_date = faker.date_time(tzinfo=tz) srcset = ', '.join( ' '.join((faker.image_url(width=w), '{0}w'.format(w))) for w in ('1200', '1024', '300') ) sizes = "(max-width: 1200px) 100vw, 1200px" content = tpl.format(image_url, srcset, sizes) feed = self.feed('Some blog', title, content, post_url, published=publish_date, summary=summary) post = blogpost(feed) assert post['title'] == title assert post['link'] == post_url assert post['summary'] == summary assert_equal_dates(post['date'], publish_date) assert post['image_url'] == image_url assert post['srcset'] == srcset assert post['sizes'] == sizes
def test_blogpost_with_thumbnail_as_enclosure(self, blogpost, mime): title = faker.sentence() post_url = faker.uri() image_url = faker.image_url() tz = pytz.timezone(faker.timezone()) publish_date = faker.date_time(tzinfo=tz) content = faker.sentence() html_content = '<div>{0}</div>'.format(content) feed = self.feed('Some blog', title, html_content, post_url, published=publish_date, enclosure={ 'type': mime, 'url': image_url }) post = blogpost(feed) assert post['title'] == title assert post['link'] == post_url assert post['summary'] == content assert_equal_dates(post['date'], publish_date) assert post['image_url'] == image_url assert 'srcset' not in post assert 'sizes' not in post
def test_blogpost_with_first_image_as_thumbnail_and_summary( self, blogpost): title = faker.sentence() post_url = faker.uri() image_url = faker.image_url() summary = faker.sentence() tz = pytz.timezone(faker.timezone()) publish_date = faker.date_time(tzinfo=tz) content = '<p><img class="whatever" src="{0}" /> Whatever whatever</p>'.format( image_url) feed = self.feed('Some blog', title, content, post_url, published=publish_date, summary=summary) post = blogpost(feed) assert post['title'] == title assert post['link'] == post_url assert post['summary'] == summary assert_equal_dates(post['date'], publish_date) assert post['image_url'] == image_url assert 'srcset' not in post assert 'sizes' not in post
def test_render_home_with_blog_with_thumbnail(self, home): '''It should render the home page with the latest blog article and its thumbnail''' post = { 'title': faker.name(), 'link': faker.uri(), 'summary': faker.sentence(), 'date': faker.date_time(), 'image_url': faker.image_url(), } response = home(post) assert200(response) page = response.data.decode('utf8') assert post['title'] in page assert post['link'] in page assert post['summary'] in page assert post['image_url'] in page assert 'blog-thumbnail' in page
def test_render_home_with_blog_with_thumbnail(self, home): '''It should render the home page with the latest blog article and its thumbnail''' post = { 'title': faker.name(), 'link': faker.uri(), 'summary': faker.sentence(), 'date': faker.date_time(), 'image_url': faker.image_url(), } response = home(post) assert200(response) page = response.data.decode('utf8') assert post['title'] in page assert post['link'] in page assert post['summary'] in page assert post['image_url'] in page assert 'blog-thumbnail' in page
def test_blogpost_with_first_image_as_thumbnail(self, blogpost): title = faker.sentence() post_url = faker.uri() image_url = faker.image_url() summary = faker.sentence() tz = pytz.timezone(faker.timezone()) publish_date = faker.date_time(tzinfo=tz) content = '<p><img class="whatever" src="{0}" /> {1}</p>'.format(image_url, summary) feed = self.feed('Some blog', title, content, post_url, published=publish_date) post = blogpost(feed) assert post['title'] == title assert post['link'] == post_url assert post['summary'] == summary assert_equal_dates(post['date'], publish_date) assert post['image_url'] == image_url assert 'srcset' not in post assert 'sizes' not in post
def test_blogpost_with_thumbnail_as_media_thumbnail(self, blogpost): title = faker.sentence() post_url = faker.uri() image_url = faker.image_url() tz = pytz.timezone(faker.timezone()) publish_date = faker.date_time(tzinfo=tz) content = faker.sentence() html_content = '<div>{0}</div>'.format(content) feed = self.feed('Some blog', title, html_content, post_url, published=publish_date, media_thumbnail=image_url) post = blogpost(feed) assert post['title'] == title assert post['link'] == post_url assert post['summary'] == content assert_equal_dates(post['date'], publish_date) assert post['image_url'] == image_url assert 'srcset' not in post assert 'sizes' not in post