def landingpage(request): user_ids = [s.user_id for s in SocialUser.all()] return render( request, 'landingpage.html', { 'video_count': len(list(Video.all())), 'group_count': len(list(Group.all())), 'socialuser_count': len(set(user_ids)), 'socialuser_all_count': len(user_ids), 'overall_suggestions_count': statistics.overall_suggestions_count(), 'overall_suggestions_user_count': statistics.overall_suggestions_user_count(), 'suggestions_user_count': statistics.suggestions_user_count(), 'overall_watch_count': statistics.overall_watch_count(), 'overall_watch_user_count': statistics.overall_watch_user_count(), 'watch_user_count': statistics.watch_user_count(), 'overall_dismiss_count': statistics.overall_dismiss_count(), 'overall_dismiss_user_count': statistics.overall_dismiss_user_count(), 'dismiss_user_count': statistics.dismiss_user_count(), 'user_watches': statistics.user_watches(), })
def test_get_list_view(self): response = self.client.get(reverse('videos:list')) self.assertEqual(response.status_code, 200) self.assertIn('videos', response.context) videos = list(response.context['videos']) all_videos = Video.all() self.assertTrue(all(video in all_videos for video in videos))
def test_post_delete_view(self): video = Video.get(1) response = self.client.post(reverse('videos:delete', kwargs={'pk': video.id}), follow=True) self.assertRedirects(response, reverse('videos:list')) self.assertNotIn(video, Video.all())