Example #1
0
 def test_license_no_uses_still_doesnt_limit(self):
     l = License()
     l.target = self.category
     l.max_applications = 2
     l.save()
     self.assert_equals([],
                        License.objects.unapplicable_for_model(Category))
Example #2
0
    def test_license_with_over_max_number_of_uses_does_limit(self):
        l = License()
        l.target = self.category
        l.max_applications = 2
        l.applications = 20
        l.save()
        self.assert_equals([self.category.pk], License.objects.unapplicable_for_model(Category))

        qset = Category.objects.order_by('pk')
        self.assert_equals(list(qset.exclude(pk=self.category.pk)), list(License.objects.filter_queryset(qset)))
Example #3
0
    def test_license_with_allowed_number_of_uses_still_doesnt_limit(self):
        l = License()
        l.target = self.category
        l.max_applications = 2
        l.applications = 1
        l.save()

        qset = Category.objects.order_by('pk')
        self.assert_equals([], License.objects.unapplicable_for_model(Category))
        self.assert_equals(list(qset), list(License.objects.filter_queryset(qset)))
Example #4
0
    def test_license_with_over_max_number_of_uses_does_limit(self):
        l = License()
        l.target = self.category
        l.max_applications = 2
        l.applications = 20
        l.save()
        self.assert_equals([self.category.pk],
                           License.objects.unapplicable_for_model(Category))

        qset = Category.objects.order_by('pk')
        self.assert_equals(list(qset.exclude(pk=self.category.pk)),
                           list(License.objects.filter_queryset(qset)))
Example #5
0
    def test_license_with_allowed_number_of_uses_still_doesnt_limit(self):
        l = License()
        l.target = self.category
        l.max_applications = 2
        l.applications = 1
        l.save()

        qset = Category.objects.order_by('pk')
        self.assert_equals([],
                           License.objects.unapplicable_for_model(Category))
        self.assert_equals(list(qset),
                           list(License.objects.filter_queryset(qset)))
Example #6
0
 def test_license_no_uses_still_doesnt_limit(self):
     l = License()
     l.target = self.category
     l.max_applications = 2
     l.save()
     self.assert_equals([], License.objects.unapplicable_for_model(Category))