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


Python FS.storage_usage方法代码示例

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


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

示例1: TestFS

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

#.........这里部分代码省略.........
    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"
        dst = "test/xyz"
        print(self.fs.symlink(src, dst))
        calls = [
            call().__enter__(),
            call().__enter__().run("ln -sf test/tgz.txt test/xyz"),
            call().__exit__(None, None, None),
        ]
        mock_StartShell.assert_has_calls(calls)

    @patch("jnpr.junos.Device.execute")
    def test_storage_usage(self, mock_execute):
        mock_execute.side_effect = self._mock_manager
        self.assertEqual(
            self.fs.storage_usage(),
            {
                "/dev/abc": {
                    "avail_block": 234234,
                    "used_blocks": 2346455,
                    "used_pct": "1",
                    "mount": "/",
                    "total_blocks": 567431,
                    "avail": "2F",
                    "used": "481M",
                    "total": "4F",
                }
            },
        )

    @patch("jnpr.junos.Device.execute")
    def test_directory_usage(self, mock_execute):
        mock_execute.side_effect = self._mock_manager
        self.assertEqual(
            self.fs.directory_usage(path="/var/tmp", depth=1),
            {
                "/var/tmp": {"blocks": 456076, "bytes": 233510912, "size": "223M"},
                "/var/tmp/gres-tp": {"blocks": 68, "bytes": 34816, "size": "34K"},
                "/var/tmp/install": {"blocks": 4, "bytes": 2048, "size": "2.0K"},
                "/var/tmp/pics": {"blocks": 4, "bytes": 2048, "size": "2.0K"},
                "/var/tmp/rtsdb": {"blocks": 4, "bytes": 2048, "size": "2.0K"},
                "/var/tmp/sec-download": {"blocks": 8, "bytes": 4096, "size": "4.0K"},
                "/var/tmp/vi.recover": {"blocks": 4, "bytes": 2048, "size": "2.0K"},
            },
        )
开发者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 storage_usage [as 别名]

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

    @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'
        dst = 'test/xyz'
        print(self.fs.symlink(src, dst))
        calls = [
            call().__enter__(),
            call().__enter__().run('ln -sf test/tgz.txt test/xyz'),
            call().__exit__(None, None, None)]
        mock_StartShell.assert_has_calls(calls)

    @patch('jnpr.junos.Device.execute')
    def test_storage_usage(self, mock_execute):
        mock_execute.side_effect = self._mock_manager
        self.assertEqual(self.fs.storage_usage(),
                         {'/dev/abc':
                          {'avail_block': 234234,
                           'used_blocks': 2346455, 'used_pct': '1',
                           'mount': '/', 'total_blocks': 567431,
                           'avail': '2F', 'used': '481M',
                           'total': '4F'}})

    @patch('jnpr.junos.Device.execute')
    def test_directory_usage(self, mock_execute):
        mock_execute.side_effect = self._mock_manager
        self.assertEqual(self.fs.directory_usage(path="/var/tmp", depth=1),
                         {'/var/tmp': {'blocks': 456076, 'bytes': 233510912,
                                       'size': '223M'},
                          '/var/tmp/gres-tp': {'blocks': 68, 'bytes': 34816,
                                               'size': '34K'},
                          '/var/tmp/install': {'blocks': 4, 'bytes': 2048,
                                               'size': '2.0K'},
                          '/var/tmp/pics': {'blocks': 4, 'bytes': 2048,
                                            'size': '2.0K'},
                          '/var/tmp/rtsdb': {'blocks': 4, 'bytes': 2048,
                                             'size': '2.0K'},
                          '/var/tmp/sec-download': {'blocks': 8, 'bytes': 4096,
                                                    'size': '4.0K'},
                          '/var/tmp/vi.recover': {'blocks': 4, 'bytes': 2048,
                                                  'size': '2.0K'}}
                         )

    @patch('jnpr.junos.Device.execute')
    def test_directory_usage_error(self, mock_execute):
        mock_execute.return_value = etree.fromstring("""
开发者ID:ydnath,项目名称:py-junos-eznc,代码行数:70,代码来源:test_fs.py


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