Ejemplo n.º 1
0
 def test_creates_new_link(self):
     old_ver = VersionedTextFile.objects.create(data=factory.make_string())
     versioned_text_file_field = VersionedTextFileField(initial=old_ver)
     data = factory.make_string()
     new_ver = versioned_text_file_field.clean(data)
     self.assertEquals(data, new_ver.data)
     self.assertEquals(old_ver, new_ver.previous_version)
Ejemplo n.º 2
0
 def test_create_new_accepts_dict_with_comment(self):
     data = factory.make_string()
     comment = factory.make_name('comment')
     versioned_text_file_field = VersionedTextFileField()
     versioned_text_file = versioned_text_file_field.clean(
         {'data': data, 'comment': comment})
     self.assertEquals(data, versioned_text_file.data)
     self.assertEquals(comment, versioned_text_file.comment)
     self.assertIsNone(versioned_text_file.previous_version)
Ejemplo n.º 3
0
 def test_creates_new_link_accepts_dict(self):
     old_ver = VersionedTextFile.objects.create(data=factory.make_string())
     versioned_text_file_field = VersionedTextFileField(initial=old_ver)
     data = factory.make_string()
     comment = factory.make_name('comment')
     new_ver = versioned_text_file_field.clean(
         {'new_data': data, 'comment': comment})
     self.assertEquals(data, new_ver.data)
     self.assertEquals(comment, new_ver.comment)
     self.assertEquals(old_ver, new_ver.previous_version)
Ejemplo n.º 4
0
 def test_update_does_nothing_on_none(self):
     data = VersionedTextFile.objects.create(data=factory.make_string())
     versioned_text_file_field = VersionedTextFileField(initial=data)
     self.assertEquals(data, versioned_text_file_field.clean(None))
Ejemplo n.º 5
0
 def test_creates_new(self):
     data = factory.make_string()
     versioned_text_file_field = VersionedTextFileField()
     versioned_text_file = versioned_text_file_field.clean(data)
     self.assertEquals(data, versioned_text_file.data)
     self.assertIsNone(versioned_text_file.previous_version)