def test_get_context_data_should_include_posts(self): user = User.objects.create_user(username='******', password='******') Post.objects.create( title = 'Test Title', content = 'test content', author = user, published_at = date.today() ) view = views.Home() context = view.get_context_data(object_list=[]) self.assertIn('posts', context)
def test_should_group_sponsor_into_groups_of_six(self): groups = views.Home().sponsor_groups() self.assertEqual(2, len(groups)) self.assertEqual(6, len(groups[0]))
def test_get_context_data_should_include_all_sponsor_groups_in_the_context(self): view = views.Home() context = view.get_context_data(object_list=[]) sponsors = list(context["sponsor_groups"]) self.assertEqual(view.sponsor_groups(), sponsors)