-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds two delete methods through the API and a newly created admin tool. Signed-off-by: David Brown <dmlb2000@gmail.com>
- Loading branch information
Showing
17 changed files
with
268 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
"""File used to unit test the pacifica archive interface.""" | ||
from os.path import sep | ||
import unittest | ||
import mock | ||
from pacifica.archiveinterface.__main__ import cmd | ||
from .common_setup_test import SetupTearDown | ||
|
||
|
||
class TestPosixBackendArchive(unittest.TestCase, SetupTearDown): | ||
"""Test the Posix backend archive.""" | ||
|
||
@mock.patch('os.unlink') | ||
@mock.patch('os.chmod') | ||
def test_admin_cmd(self, mock_chmod, mock_unlink): | ||
"""Test admin command.""" | ||
temp_fd = open('{}tmp{}1234'.format(sep, sep), 'w') | ||
temp_fd.close() | ||
del temp_fd | ||
mock_unlink.return_value = 0 | ||
mock_chmod.return_value = 0 | ||
res = cmd(['delete', '1234']) | ||
mock_unlink.assert_called_with('{}tmp{}1234'.format(sep, sep)) | ||
mock_chmod.assert_called_with('{}tmp{}1234'.format(sep, sep), 0o200) | ||
self.assertEqual(res, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
"""Setup and tear down the class cleaning up files.""" | ||
import stat | ||
from os import remove, chmod, rmdir | ||
from os.path import isdir, isfile, join, sep | ||
|
||
|
||
class SetupTearDown(object): | ||
"""Clean up temporary files before and after tests.""" | ||
|
||
@staticmethod | ||
def _cleanup(): | ||
"""Clean up temporary files in /tmp.""" | ||
file_list = [ | ||
'{}{}'.format(sep, join('tmp', '1234')), | ||
'{}{}'.format(sep, join('tmp', '1235')), | ||
'{}{}'.format(sep, join('tmp', 'cptests', '1235')), | ||
'{}{}'.format(sep, join('tmp', '12345')), | ||
'{}{}'.format(sep, join('tmp', '5678')), | ||
'{}{}'.format(sep, join('tmp', '15', 'cd', '5b', '75bcd15')), | ||
'{}{}'.format(sep, join('tmp', 'a', 'b', 'd')) | ||
] | ||
dir_list = [ | ||
'{}{}'.format(sep, join('tmp', 'cptests')), | ||
'{}{}'.format(sep, join('tmp', 'a', 'b')), | ||
'{}{}'.format(sep, join('tmp', 'a')), | ||
'{}{}'.format(sep, join('tmp', '15', 'cd', '5b')), | ||
'{}{}'.format(sep, join('tmp', '15', 'cd')), | ||
'{}{}'.format(sep, join('tmp', '15')), | ||
'{}{}'.format(sep, join('tmp', '39')), | ||
] | ||
for fname in file_list: | ||
if isfile(fname): | ||
chmod(fname, stat.S_IWRITE) | ||
remove(fname) | ||
for dname in dir_list: | ||
if isdir(dname): | ||
chmod(dname, stat.S_IWRITE) | ||
rmdir(dname) | ||
|
||
def setup_method(self, *_args, **_kwargs): | ||
"""Call cleanup.""" | ||
self._cleanup() | ||
|
||
def teardown_method(self, *_args, **_kwargs): | ||
"""Call cleanup.""" | ||
self._cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.