def test_notification_with_love(self): num_notification_before = len(get_notifications(self.user)) self.assertEqual(1, num_notification_before) self.client.login(username='******', password='******') self.client.get(reverse('blog_love', args=[self.blog.id])) num_notification_after_love = len(get_notifications(self.user)) self.assertEqual(2, num_notification_after_love) self.client.logout()
def test_notification_love_unlove_love(self): self.client.login(username='******', password='******') self.client.get(reverse('blog_love', args=[self.blog.id])) self.assertEqual(2, len(get_notifications(self.user))) self.client.get(reverse('blog_unlove', args=[self.blog.id])) self.assertEqual(2, len(get_notifications(self.user))) self.client.get(reverse('blog_love', args=[self.blog.id])) self.assertEqual(2, len(get_notifications(self.user))) self.client.logout()
def get(self, request): user = TwitterUser.objects.get(username=request.user) following = user.following.all() tweets = Tweet.objects.filter(author__in=following) my_tweets = Tweet.objects.filter(author=user).values() tweets = tweets.union(my_tweets).order_by('-date') tweet_count = Tweet.objects.filter(author=user).count() follow_count = user.following.all().count() notification_count = get_notifications(request) return render( request, 'index.html', { 'user': user, 'tweets': tweets, 'tweet_count': tweet_count, 'follow_count': follow_count, 'following': following, 'notification_count': notification_count })
def site_information(request): place_form = BlogPlaceFilterForm() if request.GET.get("country") or request.GET.get("city"): place_form = BlogPlaceFilterForm(request.GET) return { "settings": settings, "SITE_NAME": settings.SITE_NAME, "ORGANIZATION_NAME": settings.ORGANIZATION_NAME, "SITE_LOGO": settings.SITE_LOGO, "SITE_LOGO_EMAIL": settings.SITE_LOGO_EMAIL, "AVATAR_SIZE": settings.AVATAR_SIZE, "AVATAR_TOP_SIZE": settings.AVATAR_TOP_SIZE, "BLOG_PREVIEW_SIZE": settings.BLOG_PREVIEW_SIZE, "USE_TZ": settings.USE_TZ, "PRIVATE": settings.PRIVATE, "notifications": get_notifications(request.user)[: settings.NOTIFICATION_POPUP_NUM], "category_filter": Category.objects.all(), "place_form": place_form, }
def test_notification_page_after_viewed(self): self.assertEqual(1, len(get_notifications(self.user))) self.client.login(username='******', password='******') self.client.get(reverse('notification_view')) self.assertEqual(0, len(get_notifications(self.user))) self.client.logout()
def test_get_notifications(self): self.assertEqual(1, len(get_notifications(self.user))) self.assertEqual(0, len(get_notifications(self.user_with_notification)))