Esempio n. 1
0
    def test_usage(self):
        '''
        Test if it shows in which disk the chunks are allocated.
        '''
        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Salt'})
        with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
            mock = MagicMock(return_value={'Salt': 'salt'})
            with patch.object(btrfs, '_usage_specific', mock):
                self.assertDictEqual(btrfs.usage('/dev/sda1'),
                                     {'Salt': 'salt'})

        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Unallocated:\n'})
        with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
            mock = MagicMock(return_value={'/dev/sda1': True})
            with patch.object(btrfs, '_usage_unallocated', mock):
                self.assertDictEqual(btrfs.usage('/dev/sda1'),
                                     {'unallocated': {'/dev/sda1': True}})

        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Overall:\n'})
        with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
            mock = MagicMock(return_value={'/dev/sda1': True})
            with patch.object(btrfs, '_usage_overall', mock):
                self.assertDictEqual(btrfs.usage('/dev/sda1'),
                                     {'overall': {'/dev/sda1': True}})
Esempio n. 2
0
    def test_usage(self):
        '''
        Test if it shows in which disk the chunks are allocated.
        '''
        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Salt'})
        with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
            mock = MagicMock(return_value={'Salt': 'salt'})
            with patch.object(btrfs, '_usage_specific', mock):
                self.assertDictEqual(btrfs.usage('/dev/sda1'),
                                     {'Salt': 'salt'})

        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Unallocated:\n'})
        with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
            mock = MagicMock(return_value={'/dev/sda1': True})
            with patch.object(btrfs, '_usage_unallocated', mock):
                self.assertDictEqual(btrfs.usage('/dev/sda1'),
                                     {'unallocated': {'/dev/sda1': True}})

        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Overall:\n'})
        with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
            mock = MagicMock(return_value={'/dev/sda1': True})
            with patch.object(btrfs, '_usage_overall', mock):
                self.assertDictEqual(btrfs.usage('/dev/sda1'),
                                     {'overall': {'/dev/sda1': True}})
Esempio n. 3
0
    def test_usage(self):
        """
        Test if it shows in which disk the chunks are allocated.
        """
        with patch("salt.utils.fsutils._verify_run", MagicMock(return_value=True)):
            mock = MagicMock(
                return_value={"retcode": 1, "stderr": "", "stdout": "Salt"}
            )
            with patch.dict(btrfs.__salt__, {"cmd.run_all": mock}):
                mock = MagicMock(return_value={"Salt": "salt"})
                with patch.object(btrfs, "_usage_specific", mock):
                    self.assertDictEqual(btrfs.usage("/dev/sda1"), {"Salt": "salt"})

            mock = MagicMock(
                return_value={"retcode": 1, "stderr": "", "stdout": "Unallocated:\n"}
            )
            with patch.dict(btrfs.__salt__, {"cmd.run_all": mock}):
                mock = MagicMock(return_value={"/dev/sda1": True})
                with patch.object(btrfs, "_usage_unallocated", mock):
                    self.assertDictEqual(
                        btrfs.usage("/dev/sda1"), {"unallocated": {"/dev/sda1": True}}
                    )

            mock = MagicMock(
                return_value={"retcode": 1, "stderr": "", "stdout": "Overall:\n"}
            )
            with patch.dict(btrfs.__salt__, {"cmd.run_all": mock}):
                mock = MagicMock(return_value={"/dev/sda1": True})
                with patch.object(btrfs, "_usage_overall", mock):
                    self.assertDictEqual(
                        btrfs.usage("/dev/sda1"), {"overall": {"/dev/sda1": True}}
                    )