@@ -190,6 +190,41 @@ def test_past_future_ordering(self):
190190
191191
192192class ViewsTestCase (DateTimeMixin , TestCase ):
193+ def test_detail_view_html_meta (self ):
194+ headline = "Pride and Prejudice - Review"
195+ author = "Jane Austen"
196+ pub_date = date (2005 , 7 , 21 )
197+ blog_entry = Entry .objects .create (
198+ pub_date = pub_date ,
199+ is_active = True ,
200+ headline = headline ,
201+ slug = "a" ,
202+ author = author ,
203+ )
204+ blog_description = "Posted by Jane Austen on July 21, 2005"
205+ self .assertEqual (blog_entry .description , blog_description )
206+
207+ blog_url = blog_entry .get_absolute_url ()
208+ response = self .client .get (blog_url )
209+ self .assertEqual (response .status_code , 200 )
210+
211+ expected_html_meta_tags = [
212+ f'<meta name="description" content="{ blog_description } " />' ,
213+ '<meta property="og:type" content="article" />' ,
214+ f'<meta property="og:title" content="{ headline } " />' ,
215+ f'<meta property="og:description" content="{ blog_description } " />' ,
216+ '<meta property="og:article:published_time" content="2005-07-21T00:00:00" />' ,
217+ f'<meta property="og:article:author" content="{ author } " />' ,
218+ '<meta property="og:image:alt" content="Django logo" />' ,
219+ f'<meta property="og:url" content="{ blog_url } " />' ,
220+ '<meta property="og:site_name" content="Django Project" />' ,
221+ '<meta property="twitter:card" content="summary" />' ,
222+ '<meta property="twitter:creator" content="djangoproject" />' ,
223+ '<meta property="twitter:site" content="djangoproject" />' ,
224+ ]
225+ for expected_html_meta_tag in expected_html_meta_tags :
226+ self .assertContains (response , expected_html_meta_tag , html = True )
227+
193228 def test_staff_with_change_permission_can_see_unpublished_detail_view (self ):
194229 """
195230 Staff users with change permission on BlogEntry can't see unpublished entries
0 commit comments