本文整理汇总了Python中jnpr.junos.utils.fs.FS.tgz方法的典型用法代码示例。如果您正苦于以下问题:Python FS.tgz方法的具体用法?Python FS.tgz怎么用?Python FS.tgz使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jnpr.junos.utils.fs.FS
的用法示例。
在下文中一共展示了FS.tgz方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFS
# 需要导入模块: from jnpr.junos.utils.fs import FS [as 别名]
# 或者: from jnpr.junos.utils.fs.FS import tgz [as 别名]
#.........这里部分代码省略.........
path = "test/abc"
self.fs.dev.rpc.file_delete = MagicMock(return_value=False)
self.assertFalse(self.fs.rm(path))
self.fs.dev.rpc.file_delete.assert_called_once_with(path="test/abc")
def test_copy_return_true(self):
self.fs.dev.rpc.file_copy = MagicMock()
initial = "test/abc"
final = "test/xyz"
self.assertTrue(self.fs.cp(initial, final))
self.fs.dev.rpc.file_copy.assert_called_once_with(source="test/abc", destination="test/xyz")
def test_copy_return_false(self):
initial = "test/abc"
final = "test/xyz"
self.fs.dev.rpc.file_copy = MagicMock(side_effect=Exception)
self.assertFalse(self.fs.cp(initial, final))
self.fs.dev.rpc.file_copy.assert_called_once_with(source="test/abc", destination="test/xyz")
def test_move_return_true(self):
self.fs.dev.rpc.file_rename = MagicMock(return_value=True)
initial = "test/abc"
final = "test/xyz"
self.assertTrue(self.fs.mv(initial, final))
self.fs.dev.rpc.file_rename.assert_called_once_with(source="test/abc", destination="test/xyz")
def test_move_return_false(self):
initial = "test/abc"
final = "test/xyz"
self.fs.dev.rpc.file_rename = MagicMock(return_value=False)
self.assertFalse(self.fs.mv(initial, final))
self.fs.dev.rpc.file_rename.assert_called_once_with(source="test/abc", destination="test/xyz")
def test_tgz_return_true(self):
src = "test/tgz.txt"
dst = "test/xyz"
self.fs.dev.rpc.file_archive = MagicMock(return_value=True)
self.assertTrue(self.fs.tgz(src, dst))
self.fs.dev.rpc.file_archive.assert_called_once_with(
source="test/tgz.txt", destination="test/xyz", compress=True
)
@patch("jnpr.junos.Device.execute")
def test_tgz_return_error(self, mock_execute):
mock_execute.side_effect = self._mock_manager
src = "test/tgz.txt"
dst = "test/xyz"
self.assertTrue("testing tgz" in self.fs.tgz(src, dst))
@patch("jnpr.junos.utils.fs.StartShell")
def test_rmdir(self, mock_StartShell):
path = "test/rmdir"
print(self.fs.rmdir(path))
calls = [call().__enter__(), call().__enter__().run("rmdir test/rmdir"), call().__exit__(None, None, None)]
mock_StartShell.assert_has_calls(calls)
@patch("jnpr.junos.utils.fs.StartShell")
def test_mkdir(self, mock_StartShell):
path = "test/mkdir"
print(self.fs.mkdir(path))
calls = [call().__enter__(), call().__enter__().run("mkdir -p test/mkdir"), call().__exit__(None, None, None)]
mock_StartShell.assert_has_calls(calls)
@patch("jnpr.junos.utils.fs.StartShell")
def test_symlink(self, mock_StartShell):
src = "test/tgz.txt"
示例2: TestFS
# 需要导入模块: from jnpr.junos.utils.fs import FS [as 别名]
# 或者: from jnpr.junos.utils.fs.FS import tgz [as 别名]
#.........这里部分代码省略.........
final = 'test/xyz'
self.assertTrue(self.fs.cp(initial, final))
self.fs.dev.rpc.file_copy.assert_called_once_with(
source='test/abc',
destination='test/xyz')
def test_copy_return_false(self):
initial = 'test/abc'
final = 'test/xyz'
self.fs.dev.rpc.file_copy = MagicMock(side_effect=Exception)
self.assertFalse(self.fs.cp(initial, final))
self.fs.dev.rpc.file_copy.assert_called_once_with(
source='test/abc',
destination='test/xyz')
def test_move_return_true(self):
self.fs.dev.rpc.file_rename = MagicMock(return_value=True)
initial = 'test/abc'
final = 'test/xyz'
self.assertTrue(self.fs.mv(initial, final))
self.fs.dev.rpc.file_rename.assert_called_once_with(
source='test/abc',
destination='test/xyz')
def test_move_return_false(self):
initial = 'test/abc'
final = 'test/xyz'
self.fs.dev.rpc.file_rename = MagicMock(return_value=False)
self.assertFalse(self.fs.mv(initial, final))
self.fs.dev.rpc.file_rename.assert_called_once_with(
source='test/abc',
destination='test/xyz')
def test_tgz_return_true(self):
src = 'test/tgz.txt'
dst = 'test/xyz'
self.fs.dev.rpc.file_archive = MagicMock(return_value=True)
self.assertTrue(self.fs.tgz(src, dst))
self.fs.dev.rpc.file_archive.assert_called_once_with(
source='test/tgz.txt',
destination='test/xyz', compress=True)
@patch('jnpr.junos.Device.execute')
def test_tgz_return_error(self, mock_execute):
mock_execute.side_effect = self._mock_manager
src = 'test/tgz.txt'
dst = 'test/xyz'
self.assertTrue('testing tgz' in self.fs.tgz(src, dst))
@patch('jnpr.junos.utils.fs.StartShell')
def test_rmdir(self, mock_StartShell):
path = 'test/rmdir'
print(self.fs.rmdir(path))
calls = [
call().__enter__(),
call().__enter__().run('rmdir test/rmdir'),
call().__exit__(None, None, None)]
mock_StartShell.assert_has_calls(calls)
@patch('jnpr.junos.utils.fs.StartShell')
def test_mkdir(self, mock_StartShell):
path = 'test/mkdir'
print(self.fs.mkdir(path))
calls = [
call().__enter__(),
call().__enter__().run('mkdir -p test/mkdir'),