示例#1
0
    def test_file_exists_for_real_file(self):
        """Test LOCAL UPLOADER file_exists returns True if the file exists"""
        u = LocalUploader()
        u.upload_folder = tempfile.mkdtemp()
        file = FileStorage(filename='test.jpg')
        container = 'mycontainer'
        u.upload_file(file, container=container)

        assert u.file_exists('test.jpg', container) is True
    def test_file_exists_for_real_file(self):
        """Test LOCAL UPLOADER file_exists returns True if the file exists"""
        u = LocalUploader()
        u.upload_folder = tempfile.mkdtemp()
        file = FileStorage(filename='test.jpg')
        container = 'mycontainer'
        u.upload_file(file, container=container)

        assert u.file_exists('test.jpg', container) is True
示例#3
0
 def test_local_uploader_upload_fails(self, mock):
     """Test LOCAL UPLOADER upload fails."""
     u = LocalUploader()
     file = FileStorage(filename='test.jpg')
     res = u.upload_file(file, container='user_3')
     err_msg = ("Upload file should return False, \
                as there is an exception")
     assert res is False, err_msg
示例#4
0
 def test_local_uploader_upload_fails(self, mock):
     """Test LOCAL UPLOADER upload fails."""
     u = LocalUploader()
     file = FileStorage(filename='test.jpg')
     res = u.upload_file(file, container='user_3')
     err_msg = ("Upload file should return False, \
                as there is an exception")
     assert res is False, err_msg
 def test_local_uploader_upload_wrong_file(self, mock):
     """Test LOCAL UPLOADER upload works with wrong extension."""
     mock.save.return_value = None
     u = LocalUploader()
     file = FileStorage(filename='test.txt')
     res = u.upload_file(file, container='user_3')
     err_msg = ("Upload file should return False, \
                as this extension is not allowed")
     assert res is False, err_msg
 def test_local_uploader_upload_correct_file(self, mock):
     """Test LOCAL UPLOADER upload works."""
     mock.save.return_value = None
     u = LocalUploader()
     file = FileStorage(filename='test.jpg')
     res = u.upload_file(file, container='user_3')
     err_msg = ("Upload file should return True, \
                as this extension is allowed")
     assert res is True, err_msg
示例#7
0
 def test_local_uploader_upload_wrong_file(self, mock):
     """Test LOCAL UPLOADER upload works with wrong extension."""
     mock.save.return_value = None
     u = LocalUploader()
     file = FileStorage(filename='test.txt')
     res = u.upload_file(file, container='user_3')
     err_msg = ("Upload file should return False, \
                as this extension is not allowed")
     assert res is False, err_msg
示例#8
0
 def test_local_uploader_upload_correct_file(self, mock):
     """Test LOCAL UPLOADER upload works."""
     mock.save.return_value = None
     u = LocalUploader()
     file = FileStorage(filename='test.jpg')
     res = u.upload_file(file, container='user_3')
     err_msg = ("Upload file should return True, \
                as this extension is allowed")
     assert res is True, err_msg
 def test_local_folder_is_created(self, mock):
     """Test LOCAL UPLOADER folder creation works."""
     mock.save.return_value = True
     u = LocalUploader()
     u.upload_folder = tempfile.mkdtemp()
     file = FileStorage(filename='test.jpg')
     container = 'mycontainer'
     res = u.upload_file(file, container=container)
     path = os.path.join(u.upload_folder, container)
     err_msg = "This local path should exist: %s" % path
     assert os.path.isdir(path) is True, err_msg
示例#10
0
 def test_local_folder_is_created(self, mock):
     """Test LOCAL UPLOADER folder creation works."""
     mock.save.return_value = True
     u = LocalUploader()
     u.upload_folder = tempfile.mkdtemp()
     file = FileStorage(filename='test.jpg')
     container = 'mycontainer'
     res = u.upload_file(file, container=container)
     path = os.path.join(u.upload_folder, container)
     err_msg = "This local path should exist: %s" % path
     assert os.path.isdir(path) is True, err_msg