Exemple #1
0
 def test_path_unchanged(self):
     with utils.NamedTemporaryDirectory() as tmp_d:
         non_existing_path = tmp_d / 'does' / 'not' / 'exist'
         self.assertFalse(non_existing_path.exists())
         utils.is_writeable(non_existing_path)
         self.assertFalse(non_existing_path.exists())
         self.assertFalse((tmp_d / 'does').exists())
Exemple #2
0
 def test_disable_backoff(self):
     path = Path('swift://AUTH_stor_test/container/test/')
     swift_opts = {'num_retries': 0}
     utils.is_writeable(path, swift_opts)
     self.mock_copy.assert_called_with(self.filename,
                                       path,
                                       swift_retry_options=swift_opts)
Exemple #3
0
 def test_container_created_in_another_client(self):
     # Simulate that container doesn't exist at the beginning, but is created after the
     # is_writeable is called.
     self.mock_exists.side_effect = [False, True]
     self.mock_remove_container.side_effect = stor.swift.ConflictError(
         'foo')
     self.assertTrue(
         utils.is_writeable('swift://AUTH_stor_test/container/'))
Exemple #4
0
 def test_path_no_perms(self):
     self.mock_copy.side_effect = stor.exceptions.FailedUploadError('foo')
     self.assertFalse(utils.is_writeable('s3://stor-test/foo/bar'))
     self.assertFalse(self.mock_remove.called)
Exemple #5
0
 def test_success(self):
     path = 's3://stor-test/foo/bar'
     self.assertTrue(utils.is_writeable(path))
     self.mock_remove.assert_called_with(
         S3Path('{}/{}'.format(path, self.filename)))
Exemple #6
0
 def test_no_trailing_slash(self):
     path = SwiftPath('swift://AUTH_stor_test/container')
     utils.is_writeable(path)  # no trailing slash
     self.mock_copy.assert_called_with(self.filename,
                                       utils.with_trailing_slash(path),
                                       swift_retry_options=None)
Exemple #7
0
 def test_path_no_perms(self):
     self.mock_copy.side_effect = stor.swift.UnauthorizedError('foo')
     self.assertFalse(
         utils.is_writeable('swift://AUTH_stor_test/container/test/'))
Exemple #8
0
 def test_existing_path_not_removed(self):
     self.mock_exists.return_value = True
     utils.is_writeable('swift://AUTH_stor_test/container/test/')
     self.assertFalse(self.mock_remove_container.called)
Exemple #9
0
 def test_path_unchanged(self):
     # Make the first call to exists() return False and the second return True.
     self.mock_exists.side_effect = [False, True]
     utils.is_writeable('swift://AUTH_stor_test/container/test/')
     self.mock_remove_container.assert_called_once_with(
         SwiftPath('swift://AUTH_stor_test/container/'))
Exemple #10
0
 def test_non_existing_path(self):
     self.mock_exists.return_value = False
     self.assertTrue(
         utils.is_writeable('swift://AUTH_stor_test/container/test/'))
Exemple #11
0
 def test_existing_path(self):
     self.mock_exists.return_value = True
     path = SwiftPath('swift://AUTH_stor_test/container/test/')
     self.assertTrue(utils.is_writeable(path))
     self.mock_remove.assert_called_with(path / self.filename)
Exemple #12
0
 def test_path_no_perms(self):
     with utils.NamedTemporaryDirectory() as tmp_d:
         os.chmod(tmp_d, stat.S_IREAD | stat.S_IRGRP | stat.S_IROTH)
         self.assertFalse(utils.is_writeable(tmp_d))
Exemple #13
0
 def test_existing_path_not_removed(self):
     with utils.NamedTemporaryDirectory() as tmp_d:
         self.assertTrue(tmp_d.exists())
         utils.is_writeable(tmp_d)
         self.assertTrue(tmp_d.exists())
Exemple #14
0
 def test_non_existing_path(self):
     with utils.NamedTemporaryDirectory() as tmp_d:
         non_existing_path = tmp_d / 'does' / 'not' / 'exist'
         self.assertFalse(utils.is_writeable(non_existing_path))
Exemple #15
0
 def test_existing_path(self):
     with utils.NamedTemporaryDirectory() as tmp_d:
         self.assertTrue(utils.is_writeable(tmp_d))