コード例 #1
0
ファイル: test_fields.py プロジェクト: ella/ella-newman
    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
ファイル: test_fields.py プロジェクト: ella/ella-newman
    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)
コード例 #3
0
ファイル: test_fields.py プロジェクト: ella/ella-newman
    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
ファイル: test_fields.py プロジェクト: jezradek/django-newman
    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)
コード例 #5
0
ファイル: test_fields.py プロジェクト: jezradek/django-newman
    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)
コード例 #6
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())
コード例 #7
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)
コード例 #8
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)
コード例 #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)