当前位置: 首页>>代码示例>>Python>>正文


Python FS.symlink方法代码示例

本文整理汇总了Python中jnpr.junos.utils.fs.FS.symlink方法的典型用法代码示例。如果您正苦于以下问题:Python FS.symlink方法的具体用法?Python FS.symlink怎么用?Python FS.symlink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jnpr.junos.utils.fs.FS的用法示例。


在下文中一共展示了FS.symlink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestFS

# 需要导入模块: from jnpr.junos.utils.fs import FS [as 别名]
# 或者: from jnpr.junos.utils.fs.FS import symlink [as 别名]

#.........这里部分代码省略.........
        )

    def test_ls_return_none(self):
        path = "test/abc"
        self.fs.dev.rpc.file_list = MagicMock()
        self.fs.dev.rpc.file_list.find.return_value = "output"
        self.assertEqual(self.fs.ls(path), None)

    @patch("jnpr.junos.utils.fs.FS._decode_file")
    def test_ls_link_path_false(self, mock_decode_file):
        mock_decode_file.get.return_value = False
        path = "test/stat/decode_file"
        self.fs.dev.rpc.file_list = MagicMock(side_effect=self._mock_manager)
        self.fs.ls(path, followlink=False)
        mock_decode_file.assert_has_calls(call().get("link"))

    def test_ls_brief_true(self):
        path = "test/stat/decode_dir"
        self.fs.dev.rpc.file_list = MagicMock(side_effect=self._mock_manager)
        self.assertEqual(
            self.fs.ls(path, brief=True), {"files": ["abc"], "path": "/var", "type": "dir", "file_count": 1, "size": 2}
        )

    def test_ls_calling___decode_dir_type_symbolic_link(self):
        path = "test/stat/decode_symbolic_link"
        self.fs.dev.rpc.file_list = MagicMock(side_effect=self._mock_manager)
        self.assertEqual(
            self.fs.ls(path),
            {
                "files": {
                    "abc": {
                        "permissions_text": "drwxr-xr-x",
                        "ts_date": "Feb 17 15:30",
                        "link": "symlink test",
                        "ts_epoc": "1392651039",
                        "owner": "root",
                        "path": "abc",
                        "size": 2,
                        "type": "link",
                        "permissions": 555,
                    }
                },
                "path": "/var",
                "type": "dir",
                "file_count": 1,
                "size": 2,
            },
        )

    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))
开发者ID:pklimai,项目名称:py-junos-eznc,代码行数:70,代码来源:test_fs.py

示例2: TestFS

# 需要导入模块: from jnpr.junos.utils.fs import FS [as 别名]
# 或者: from jnpr.junos.utils.fs.FS import symlink [as 别名]

#.........这里部分代码省略.........
                          'size': 2})

    def test_ls_return_none(self):
        path = 'test/abc'
        self.fs.dev.rpc.file_list = MagicMock()
        self.fs.dev.rpc.file_list.find.return_value = 'output'
        self.assertEqual(self.fs.ls(path), None)

    @patch('jnpr.junos.utils.fs.FS._decode_file')
    def test_ls_link_path_false(self, mock_decode_file):
        mock_decode_file.get.return_value = False
        path = 'test/stat/decode_file'
        self.fs.dev.rpc.file_list = \
            MagicMock(side_effect=self._mock_manager)
        self.fs.ls(path, followlink=False)
        mock_decode_file.assert_has_calls([call().get('link')])

    def test_ls_brief_true(self):
        path = 'test/stat/decode_dir'
        self.fs.dev.rpc.file_list = \
            MagicMock(side_effect=self._mock_manager)
        self.assertEqual(self.fs.ls(path, brief=True),
                         {'files': ['abc'], 'path': '/var',
                          'type': 'dir', 'file_count': 1, 'size': 2})

    def test_ls_calling___decode_dir_type_symbolic_link(self):
        path = 'test/stat/decode_symbolic_link'
        self.fs.dev.rpc.file_list = \
            MagicMock(side_effect=self._mock_manager)
        self.assertEqual(self.fs.ls(path),
                         {'files':
                          {'abc': {'permissions_text': 'drwxr-xr-x',
                                   'ts_date': 'Feb 17 15:30',
                                   'link': 'symlink test',
                                   'ts_epoc': '1392651039',
                                   'owner': 'root', 'path': 'abc',
                                   'size': 2, 'type': 'link',
                                   'permissions': 555}},
                          'path': '/var', 'type': 'dir', 'file_count': 1,
                          'size': 2})

    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'
开发者ID:ydnath,项目名称:py-junos-eznc,代码行数:70,代码来源:test_fs.py


注:本文中的jnpr.junos.utils.fs.FS.symlink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。