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)
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)
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)
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)