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())
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)
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)
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)
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)
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)
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)