Adding a test to make sure that new and popular are correct

pull/1/head
Raymond Yee 2012-02-01 08:27:21 -08:00
parent 3a30e22814
commit 020f4266d3
1 changed files with 23 additions and 0 deletions

23
test/querytests.py Normal file
View File

@ -0,0 +1,23 @@
from regluit.core import models
from django.db.models import Q, Count, Sum
from regluit.core import userlists
from itertools import izip
def list_popular():
work_set = models.Work.objects.annotate(wished=Count('wishlists')).order_by('-wished')
print work_set
counts={}
counts['unglued'] = work_set.filter(editions__ebooks__isnull=False).distinct().count()
counts['unglueing'] = work_set.filter(campaigns__status='ACTIVE').count()
counts['wished'] = work_set.count() - counts['unglued'] - counts['unglueing']
print counts
ungluers = userlists.work_list_users(work_set,5)
print ungluers
def list_new():
works1 = models.Work.objects.filter(wishlists__isnull=False).distinct().order_by('-created')
print works1.count()