當前位置: 首頁>>代碼示例>>Python>>正文


Python FS.mv方法代碼示例

本文整理匯總了Python中jnpr.junos.utils.fs.FS.mv方法的典型用法代碼示例。如果您正苦於以下問題:Python FS.mv方法的具體用法?Python FS.mv怎麽用?Python FS.mv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jnpr.junos.utils.fs.FS的用法示例。


在下文中一共展示了FS.mv方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestFS

# 需要導入模塊: from jnpr.junos.utils.fs import FS [as 別名]
# 或者: from jnpr.junos.utils.fs.FS import mv [as 別名]

#.........這裏部分代碼省略.........
            },
        )

    def test_rm_return_true(self):
        self.fs.dev.rpc.file_delete = MagicMock(return_value=True)
        path = "test/abc"
        self.assertTrue(self.fs.rm(path))
        self.fs.dev.rpc.file_delete.assert_called_once_with(path="test/abc")

    def test_rm_return_false(self):
        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)
開發者ID:pklimai,項目名稱:py-junos-eznc,代碼行數:69,代碼來源:test_fs.py

示例2: TestFS

# 需要導入模塊: from jnpr.junos.utils.fs import FS [as 別名]
# 或者: from jnpr.junos.utils.fs.FS import mv [as 別名]

#.........這裏部分代碼省略.........
        self.assertTrue(self.fs.rm(path))
        self.fs.dev.rpc.file_delete.assert_called_once_with(
            path='test/abc')

    def test_rm_return_false(self):
        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'
開發者ID:ydnath,項目名稱:py-junos-eznc,代碼行數:70,代碼來源:test_fs.py


注:本文中的jnpr.junos.utils.fs.FS.mv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。