move move_and_symlink to koji.util
This commit is contained in:
parent
6a6f90be1e
commit
9963877545
4 changed files with 52 additions and 59 deletions
|
|
@ -1170,6 +1170,36 @@ class TestRmtree(unittest.TestCase):
|
|||
isdir.assert_has_calls([call('mode'), call('mode')])
|
||||
lstat.assert_has_calls([call('a'), call('b')])
|
||||
|
||||
class TestMoveAndSymlink(unittest.TestCase):
|
||||
@mock.patch('koji.ensuredir')
|
||||
@mock.patch('koji.util.safer_move')
|
||||
@mock.patch('os.symlink')
|
||||
def test_valid(self, symlink, safer_move, ensuredir):
|
||||
koji.util.move_and_symlink('/dir_a/src', '/dir_b/dst', relative=False, create_dir=False)
|
||||
|
||||
ensuredir.assert_not_called()
|
||||
safer_move.assert_called_once_with('/dir_a/src', '/dir_b/dst')
|
||||
symlink.assert_called_once_with('/dir_b/dst', '/dir_a/src')
|
||||
|
||||
@mock.patch('koji.ensuredir')
|
||||
@mock.patch('koji.util.safer_move')
|
||||
@mock.patch('os.symlink')
|
||||
def test_valid_relative(self, symlink, safer_move, ensuredir):
|
||||
koji.util.move_and_symlink('/a/src', '/b/dst', relative=True, create_dir=False)
|
||||
|
||||
safer_move.assert_called_once_with('/a/src', '/b/dst')
|
||||
symlink.assert_called_once_with('../b/dst', '/a/src')
|
||||
ensuredir.assert_not_called()
|
||||
|
||||
@mock.patch('koji.ensuredir')
|
||||
@mock.patch('koji.util.safer_move')
|
||||
@mock.patch('os.symlink')
|
||||
def test_valid_create_dir(self, symlink, safer_move, ensuredir):
|
||||
koji.util.move_and_symlink('a/src', 'b/dst', relative=True, create_dir=True)
|
||||
|
||||
safer_move.assert_called_once_with('a/src', 'b/dst')
|
||||
symlink.assert_called_once_with('../b/dst', 'a/src')
|
||||
ensuredir.assert_called_once_with('b')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue