예제 #1
0
 def test_file_chunks_error(self):
     """
     Test behaviour when file.chunks() is raising an error
     """
     f1 = ContentFile('chunks fails')
     def failing_chunks():
         raise IOError
     f1.chunks = failing_chunks
     with self.assertRaises(IOError):
         self.storage.save('error.file', f1)
예제 #2
0
    def test_file_save_without_name(self):
        """
        File storage extracts the filename from the content object if no
        name is given explicitly.
        """
        self.assertFalse(self.storage.exists('test.file'))

        f = ContentFile('custom contents')
        f.name = 'test.file'

        storage_f_name = self.storage.save(None, f)

        self.assertEqual(storage_f_name, f.name)

        self.assertTrue(os.path.exists(os.path.join(self.temp_dir, f.name)))

        self.storage.delete(storage_f_name)