示例#1
0
文件: btrfs_test.py 项目: DaveQB/salt
 def test_defragment(self):
     '''
     Test if it defragment mounted BTRFS filesystem.
     '''
     ret = [{'range': '/dev/sda1',
             'mount_point': False,
             'log': False, 'passed': True}]
     mock = MagicMock(return_value={'retcode': 1,
                                    'stderr': '',
                                    'stdout': 'Salt'})
     with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
         self.assertListEqual(btrfs.defragment('/dev/sda1'), ret)
示例#2
0
 def test_defragment(self):
     '''
     Test if it defragment mounted BTRFS filesystem.
     '''
     ret = [{'range': '/dev/sda1',
             'mount_point': False,
             'log': False, 'passed': True}]
     mock = MagicMock(return_value={'retcode': 1,
                                    'stderr': '',
                                    'stdout': 'Salt'})
     with patch.dict(btrfs.__salt__, {'cmd.run_all': mock}):
         self.assertListEqual(btrfs.defragment('/dev/sda1'), ret)
示例#3
0
文件: btrfs_test.py 项目: bryson/salt
 def test_defragment(self):
     '''
     Test if it defragment mounted BTRFS filesystem.
     '''
     ret = [{'range': '/dev/sda1',
             'mount_point': False,
             'log': False, 'passed': True}]
     mock_run = MagicMock(return_value={'retcode': 1,
                                        'stderr': '',
                                        'stdout': 'Salt'})
     with patch.dict(btrfs.__salt__, {'cmd.run_all': mock_run}):
         mock_file = mock_open(read_data='/dev/sda1 / ext4 rw,data=ordered 0 0')
         with patch.object(salt.utils, 'fopen', mock_file):
             self.assertListEqual(btrfs.defragment('/dev/sda1'), ret)
示例#4
0
文件: test_btrfs.py 项目: vindir/salt
 def test_defragment(self):
     '''
     Test if it defragment mounted BTRFS filesystem.
     '''
     ret = [{
         'range': '/dev/sda1',
         'mount_point': False,
         'log': False,
         'passed': True
     }]
     mock_run = MagicMock(return_value={
         'retcode': 1,
         'stderr': '',
         'stdout': 'Salt'
     })
     with patch.dict(btrfs.__salt__, {'cmd.run_all': mock_run}):
         mock_file = mock_open(
             read_data='/dev/sda1 / ext4 rw,data=ordered 0 0')
         with patch.object(salt.utils, 'fopen', mock_file):
             self.assertListEqual(btrfs.defragment('/dev/sda1'), ret)
示例#5
0
 def test_defragment(self):
     """
     Test if it defragment mounted BTRFS filesystem.
     """
     with patch("salt.utils.fsutils._is_device", MagicMock(return_value=False)):
         with patch("os.path.exists", MagicMock(return_value=True)):
             ret = [
                 {
                     "range": "/dev/sda1",
                     "mount_point": False,
                     "log": False,
                     "passed": True,
                 }
             ]
             mock_run = MagicMock(
                 return_value={"retcode": 1, "stderr": "", "stdout": "Salt"}
             )
             with patch.dict(btrfs.__salt__, {"cmd.run_all": mock_run}):
                 mock_file = mock_open(
                     read_data="/dev/sda1 / ext4 rw,data=ordered 0 0"
                 )
                 with patch.object(salt.utils.files, "fopen", mock_file):
                     self.assertListEqual(btrfs.defragment("/dev/sda1"), ret)