def test_home_context(self): "The Flickr home page sends the correct data to templates" accounts = AccountFactory.create_batch(3) photos_1 = PhotoFactory.create_batch(2, user=accounts[0].user) photos_2 = PhotoFactory.create_batch(2, user=accounts[1].user) response = self.client.get(reverse('flickr:home')) self.assertIn('account_list', response.context) self.assertIn('photo_list', response.context) self.assertEqual(len(response.context['photo_list']), 4) self.assertIn('order', response.context) self.assertEqual(response.context['order'], 'uploaded') # Three accounts, only two of which have Photos: self.assertEqual( [account.pk for account in response.context['account_list']], [1, 2, 3])
def test_home_context(self): "The Flickr home page sends the correct data to templates" accounts = AccountFactory.create_batch(3) photos_1 = PhotoFactory.create_batch(2, user=accounts[0].user) photos_2 = PhotoFactory.create_batch(2, user=accounts[1].user) response = self.client.get(reverse('flickr:home')) self.assertIn('account_list', response.context) self.assertIn('photo_list', response.context) self.assertEqual(len(response.context['photo_list']), 4) self.assertIn('order', response.context) self.assertEqual(response.context['order'], 'uploaded') # Three accounts, only two of which have Photos: self.assertEqual( [account.pk for account in response.context['account_list']], [1,2,3] )
def test_tag_detail_context(self): "Sends the correct data to the templates" accounts = AccountFactory.create_batch(2) # The 'fish' tag page shouldn't include this dog photo: self.createDogPhoto() response = self.client.get( reverse('flickr:tag_detail', kwargs={'slug': 'fish'})) self.assertIn('account_list', response.context) self.assertEqual( [account.pk for account in response.context['account_list']], [1, 2]) self.assertIn('tag', response.context) self.assertEqual(response.context['tag'].slug, 'fish') self.assertIn('order', response.context) self.assertEqual(response.context['order'], 'uploaded') self.assertIn('photo_list', response.context) self.assertEqual(len(response.context['photo_list']), 2) self.assertEqual(response.context['photo_list'][0].title, 'Carp') self.assertEqual(response.context['photo_list'][1].title, 'Cod')
def test_tag_detail_context(self): "Sends the correct data to the templates" accounts = AccountFactory.create_batch(2) # The 'fish' tag page shouldn't include this dog photo: self.createDogPhoto() response = self.client.get(reverse('flickr:tag_detail', kwargs={'slug': 'fish'})) self.assertIn('account_list', response.context) self.assertEqual( [account.pk for account in response.context['account_list']], [1,2] ) self.assertIn('tag', response.context) self.assertEqual(response.context['tag'].slug, 'fish') self.assertIn('order', response.context) self.assertEqual(response.context['order'], 'uploaded') self.assertIn('photo_list', response.context) self.assertEqual(len(response.context['photo_list']), 2) self.assertEqual(response.context['photo_list'][0].title, 'Carp') self.assertEqual(response.context['photo_list'][1].title, 'Cod')