Exemplo n.º 1
0
 def _test_remembering_setter_unsaved(self, field):
     """A remembering setter shouldn't kick in until the doc is saved."""
     old_field = 'old_' + field
     d = DocumentFactory.build()
     setattr(d, field, 'Foo')
     assert not hasattr(
         d,
         old_field), "Doc shouldn't have %s until it's saved." % old_field
Exemplo n.º 2
0
    def test_validate_category_on_save(self):
        """Make sure invalid categories can't be saved.

        Invalid categories cause errors when viewing documents.

        """
        d = DocumentFactory.build(category=9999)
        self.assertRaises(ValidationError, d.save)
Exemplo n.º 3
0
    def test_only_localizable_allowed_children(self):
        """You can't have children for a non-localizable document."""
        # Make English rev:
        en_doc = DocumentFactory(is_localizable=False)

        # Make Deutsch translation:
        de_doc = DocumentFactory.build(parent=en_doc, locale='de')
        self.assertRaises(ValidationError, de_doc.save)
Exemplo n.º 4
0
    def test_validate_category_on_save(self):
        """Make sure invalid categories can't be saved.

        Invalid categories cause errors when viewing documents.

        """
        d = DocumentFactory.build(category=9999)
        self.assertRaises(ValidationError, d.save)
Exemplo n.º 5
0
    def test_only_localizable_allowed_children(self):
        """You can't have children for a non-localizable document."""
        # Make English rev:
        en_doc = DocumentFactory(is_localizable=False)

        # Make Deutsch translation:
        de_doc = DocumentFactory.build(parent=en_doc, locale='de')
        self.assertRaises(ValidationError, de_doc.save)
Exemplo n.º 6
0
 def test_new_doc_does_not_update_categories(self):
     """Make sure that creating a new document doesn't change the
     category of all the other documents."""
     d1 = DocumentFactory(category=20)
     assert d1.pk
     d2 = DocumentFactory.build(category=30)
     assert not d2.pk
     d2._clean_category()
     d1prime = Document.objects.get(pk=d1.pk)
     eq_(20, d1prime.category)
Exemplo n.º 7
0
 def test_new_doc_does_not_update_categories(self):
     """Make sure that creating a new document doesn't change the
     category of all the other documents."""
     d1 = DocumentFactory(category=20)
     assert d1.pk
     d2 = DocumentFactory.build(category=30)
     assert not d2.pk
     d2._clean_category()
     d1prime = Document.objects.get(pk=d1.pk)
     eq_(20, d1prime.category)
Exemplo n.º 8
0
 def _test_remembering_setter_unsaved(self, field):
     """A remembering setter shouldn't kick in until the doc is saved."""
     old_field = 'old_' + field
     d = DocumentFactory.build()
     setattr(d, field, 'Foo')
     assert not hasattr(d, old_field), "Doc shouldn't have %s until it's saved." % old_field