示例#1
0
 def test_license_no_uses_still_doesnt_limit(self):
     l = License()
     l.target = self.category
     l.max_applications = 2
     l.save()
     tools.assert_equals([],
                         License.objects.unapplicable_for_model(Category))
示例#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()
        tools.assert_equals([self.category.pk], License.objects.unapplicable_for_model(Category))

        qset = Category.objects.order_by("pk")
        tools.assert_equals(list(qset.exclude(pk=self.category.pk)), list(License.objects.filter_queryset(qset)))
示例#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")
        tools.assert_equals([], License.objects.unapplicable_for_model(Category))
        tools.assert_equals(list(qset), list(License.objects.filter_queryset(qset)))
示例#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()
        tools.assert_equals([self.category.pk],
                            License.objects.unapplicable_for_model(Category))

        qset = Category.objects.order_by('pk')
        tools.assert_equals(list(qset.exclude(pk=self.category.pk)),
                            list(License.objects.filter_queryset(qset)))
示例#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')
        tools.assert_equals([],
                            License.objects.unapplicable_for_model(Category))
        tools.assert_equals(list(qset),
                            list(License.objects.filter_queryset(qset)))
示例#6
0
 def test_license_no_uses_still_doesnt_limit(self):
     l = License()
     l.target = self.category
     l.max_applications = 2
     l.save()
     tools.assert_equals([], License.objects.unapplicable_for_model(Category))