def test_force_lang_check_tempfile(self, *args, **kwargs): with mock.patch.object(subp, "subp", return_value=(HELP_GROWPART_RESIZE, "")) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) diskdev = "/dev/sdb" partnum = 1 partdev = "/dev/sdb" ret.resize(diskdev, partnum, partdev) mockobj.assert_has_calls([ mock.call( ["growpart", "--dry-run", diskdev, partnum], env={ "LANG": "C", "TMPDIR": "/tmp" }, ), mock.call( ["growpart", diskdev, partnum], env={ "LANG": "C", "TMPDIR": "/tmp" }, ), ])
def test_mode_auto_prefers_growpart(self): subp = self.mocker.replace(util.subp, passthrough=False) subp(['growpart', '--help'], env={'LANG': 'C'}) self.mocker.result((HELP_GROWPART_RESIZE, "")) self.mocker.replay() ret = cc_growpart.resizer_factory(mode="auto") self.assertTrue(isinstance(ret, cc_growpart.ResizeGrowPart))
def test_mode_auto_prefers_parted(self): subp = self.mocker.replace(util.subp, passthrough=False) subp(['parted', '--help'], env={'LANG': 'C'}) self.mocker.result((HELP_PARTED_RESIZE, "")) self.mocker.replay() ret = cc_growpart.resizer_factory(mode="auto") self.assertTrue(isinstance(ret, cc_growpart.ResizeParted))
def test_mode_auto_prefers_growpart(self): with mock.patch.object( subp, 'subp', return_value=(HELP_GROWPART_RESIZE, "")) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) mockobj.assert_called_once_with( ['growpart', '--help'], env={'LANG': 'C'})
def test_mode_auto_prefers_growpart(self): with mock.patch.object( util, 'subp', return_value=(HELP_GROWPART_RESIZE, "")) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) mockobj.assert_called_once_with( ['growpart', '--help'], env={'LANG': 'C'})
def test_mode_auto_falls_back_to_gpart(self): with mock.patch.object(subp, 'subp', return_value=("", HELP_GPART)) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGpart) mockobj.assert_has_calls([ mock.call(['growpart', '--help'], env={'LANG': 'C'}), mock.call(['gpart', 'help'], env={'LANG': 'C'}, rcs=[0, 1]) ])
def test_mode_auto_falls_back_to_gpart(self): with mock.patch.object(subp, "subp", return_value=("", HELP_GPART)) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGpart) mockobj.assert_has_calls([ mock.call(["growpart", "--help"], env={"LANG": "C"}), mock.call(["gpart", "help"], env={"LANG": "C"}, rcs=[0, 1]), ])
def test_mode_auto_prefers_growpart(self): with mock.patch.object(subp, "subp", return_value=(HELP_GROWPART_RESIZE, "")) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) mockobj.assert_called_once_with(["growpart", "--help"], env={"LANG": "C"})
def test_force_lang_check_tempfile(self, *args, **kwargs): with mock.patch.object(subp, 'subp', return_value=(HELP_GROWPART_RESIZE, "")) as mockobj: ret = cc_growpart.resizer_factory(mode="auto") self.assertIsInstance(ret, cc_growpart.ResizeGrowPart) diskdev = '/dev/sdb' partnum = 1 partdev = '/dev/sdb' ret.resize(diskdev, partnum, partdev) mockobj.assert_has_calls([ mock.call(["growpart", '--dry-run', diskdev, partnum], env={ 'LANG': 'C', 'TMPDIR': '/tmp' }), mock.call(["growpart", diskdev, partnum], env={ 'LANG': 'C', 'TMPDIR': '/tmp' }), ])