Exemplo n.º 1
0
 def test_public_method_pub_date(self):
     qs = PublicQuerySet(PublicDefault,
         pub_date_attr='pub_date')
     self.assertEqual(
         set(PublicDefault.objects.all()),
         set(qs.all()))
     self.assertEqual(4, len(qs.all()))
     self.assertEqual(
         set(PublicDefault.objects.filter(pub_date__lte=datetime.utcnow())),
         set(qs.public()))
     self.assertEqual(2, len(qs.public()))
Exemplo n.º 2
0
 def test_public_method_is_public(self):
     qs = PublicQuerySet(PublicDefault,
         is_public_attr='is_public')
     self.assertEqual(
         set(PublicDefault.objects.all()),
         set(qs.all()))
     self.assertEqual(4, len(qs.all()))
     self.assertEqual(
         set(PublicDefault.objects.filter(is_public=True)),
         set(qs.public()))
     self.assertEqual(2, len(qs.public()))
Exemplo n.º 3
0
 def test_public_method_status(self):
     qs = PublicQuerySet(PublicStatus,
         status_attr='status',
         status_values=PublicStatus.PUBLIC_STATUS)
     self.assertEqual(
         set(PublicStatus.objects.all()),
         set(qs.all()))
     self.assertEqual(4, len(qs.all()))
     self.assertEqual(
         set(PublicStatus.objects.filter(status__in=PublicStatus.PUBLIC_STATUS)),
         set(qs.public()))
     self.assertEqual(2, len(qs.public()))
Exemplo n.º 4
0
 def test_public_method_both(self):
     qs = PublicQuerySet(PublicDefault,
         is_public_attr='is_public',
         pub_date_attr='pub_date')
     self.assertEqual(
         set(PublicDefault.objects.all()),
         set(qs.all()))
     self.assertEqual(4, len(qs.all()))
     self.assertEqual(
         set(PublicDefault.objects.filter(is_public=True, pub_date__lte=datetime.utcnow())),
         set(qs.public()))
     self.assertEqual(1, len(qs.public()))