示例#1
0
    def test_subvolume_show(self):
        '''
        Test btrfs subvolume show
        '''
        salt_mock = {
            'cmd.run_all':
            MagicMock(
                return_value={
                    'recode':
                    0,
                    'stdout':
                    '''@/var
        Name:                   var
        UUID:                   7a14...-...04
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2018-10-01 14:33:12 +0200
        Subvolume ID:           258
        Generation:             82479
        Gen at creation:        10
        Parent ID:              256
        Top level ID:           256
        Flags:                  -
        Snapshot(s):
''',
                }),
        }
        with patch.dict(btrfs.__salt__, salt_mock):
            assert btrfs.subvolume_show('/var') == {
                '@/var': {
                    'name': 'var',
                    'uuid': '7a14...-...04',
                    'parent uuid': '-',
                    'received uuid': '-',
                    'creation time': '2018-10-01 14:33:12 +0200',
                    'subvolume id': '258',
                    'generation': '82479',
                    'gen at creation': '10',
                    'parent id': '256',
                    'top level id': '256',
                    'flags': '-',
                    'snapshot(s)': '',
                },
            }
            salt_mock['cmd.run_all'].assert_called_once()
            salt_mock['cmd.run_all'].assert_called_with(
                ['btrfs', 'subvolume', 'show', '/var'])
示例#2
0
    def test_subvolume_show(self):
        """
        Test btrfs subvolume show
        """
        salt_mock = {
            "cmd.run_all":
            MagicMock(
                return_value={
                    "recode":
                    0,
                    "stdout":
                    """@/var
        Name:                   var
        UUID:                   7a14...-...04
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2018-10-01 14:33:12 +0200
        Subvolume ID:           258
        Generation:             82479
        Gen at creation:        10
        Parent ID:              256
        Top level ID:           256
        Flags:                  -
        Snapshot(s):
""",
                }),
        }
        with patch.dict(btrfs.__salt__, salt_mock):
            assert btrfs.subvolume_show("/var") == {
                "@/var": {
                    "name": "var",
                    "uuid": "7a14...-...04",
                    "parent uuid": "-",
                    "received uuid": "-",
                    "creation time": "2018-10-01 14:33:12 +0200",
                    "subvolume id": "258",
                    "generation": "82479",
                    "gen at creation": "10",
                    "parent id": "256",
                    "top level id": "256",
                    "flags": "-",
                    "snapshot(s)": "",
                },
            }
            salt_mock["cmd.run_all"].assert_called_once()
            salt_mock["cmd.run_all"].assert_called_with(
                ["btrfs", "subvolume", "show", "/var"])