示例#1
0
    def test_field_drops_dependencies_on_update(self):
        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text no boxes'
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(0, Dependency.objects.all().count())
示例#2
0
    def test_field_drops_dependencies_on_update(self):
        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text no boxes'
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(0, Dependency.objects.all().count())
示例#3
0
    def test_no_longer_using_licensed_object_lowers_its_applications(self):
        l = License(max_applications=2, applications=2)
        l.target = self.category
        l.save()

        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text, no box'
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(1, License.objects.get(pk=l.pk).applications)
示例#4
0
    def test_still_using_licensed_object_doesnt_change_its_applications(self):
        l = License(max_applications=2, applications=2)
        l.target = self.category
        l.save()

        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text {%% box inline for core.category with pk %s %%}{%% endbox %%}' % self.category.pk
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(2, License.objects.get(pk=l.pk).applications)
示例#5
0
    def test_no_longer_using_licensed_object_lowers_its_applications(self):
        l = License(max_applications=2, applications=2)
        l.target = self.category
        l.save()

        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text, no box'
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(1, License.objects.get(pk=l.pk).applications)
示例#6
0
    def test_still_using_licensed_object_doesnt_change_its_applications(self):
        l = License(max_applications=2, applications=2)
        l.target = self.category
        l.save()

        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text {%% box inline for core.category with pk %s %%}{%% endbox %%}' % self.category.pk
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(2, License.objects.get(pk=l.pk).applications)
示例#7
0
    def test_object_still_used_in_one_field_doesnt_affect_applications(self):
        l = License(max_applications=2, applications=1)
        l.target = self.category
        l.save()

        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = "some-text {%% box inline for core.category with pk %s %%}{%% endbox %%}" % self.category.pk
        self.publishable.description = self.field.clean(text)

        field2 = fields.NewmanRichTextField(
            instance=self.publishable, model=self.publishable.__class__, field_name="title"
        )
        self.publishable.title = field2.clean("no box here")
        self.publishable.save()

        tools.assert_equals(1, License.objects.get(pk=l.pk).applications)
示例#8
0
    def test_object_still_used_in_one_field_doesnt_affect_dependencies(self):
        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = "some-text {%% box inline for core.category with pk %s %%}{%% endbox %%}" % self.category.pk

        field2 = fields.NewmanRichTextField(
            instance=self.publishable, model=self.publishable.__class__, field_name="title"
        )

        self.publishable.title = field2.clean("no box here")
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(1, Dependency.objects.all().count())
        dep = Dependency.objects.all()[0]
        tools.assert_equals(self.category, dep.target)
        tools.assert_equals(self.publishable, dep.dependent)
示例#9
0
    def test_object_still_used_in_one_field_doesnt_affect_applications(self):
        l = License(max_applications=2, applications=1)
        l.target = self.category
        l.save()

        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text {%% box inline for core.category with pk %s %%}{%% endbox %%}' % self.category.pk
        self.publishable.description = self.field.clean(text)

        field2 = fields.NewmanRichTextField(
            instance=self.publishable,
            model=self.publishable.__class__,
            field_name="title",
        )
        self.publishable.title = field2.clean('no box here')
        self.publishable.save()

        tools.assert_equals(1, License.objects.get(pk=l.pk).applications)
示例#10
0
    def test_object_still_used_in_one_field_doesnt_affect_dependencies(self):
        dep = Dependency()
        dep.target = self.category
        dep.dependent = self.publishable
        dep.save()

        text = 'some-text {%% box inline for core.category with pk %s %%}{%% endbox %%}' % self.category.pk

        field2 = fields.NewmanRichTextField(
            instance=self.publishable,
            model=self.publishable.__class__,
            field_name="title",
        )

        self.publishable.title = field2.clean('no box here')
        self.publishable.description = self.field.clean(text)
        self.publishable.save()

        tools.assert_equals(1, Dependency.objects.all().count())
        dep = Dependency.objects.all()[0]
        tools.assert_equals(self.category, dep.target)
        tools.assert_equals(self.publishable, dep.dependent)