def test_reset_params(self): """ Test kuebadm.reset with parameters """ result = {"retcode": 0, "stdout": "stdout"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert (kubeadm.reset( cert_dir="/pki", cri_socket="socket", ignore_preflight_errors="all", kubeconfig="/kube.cfg", rootfs="/mnt", ) == "stdout") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "reset", "--force", "--cert-dir", "/pki", "--cri-socket", "socket", "--ignore-preflight-errors", "all", "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])
def test_reset_error(self): ''' Test kuebadm.reset error ''' result = {'retcode': 1, 'stderr': 'error'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): with pytest.raises(CommandExecutionError): assert kubeadm.reset()
def test_reset_error(self): """ Test kuebadm.reset error """ result = {"retcode": 1, "stderr": "error"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): with pytest.raises(CommandExecutionError): assert kubeadm.reset()
def test_reset(self): ''' Test kuebadm.reset without parameters ''' result = {'retcode': 0, 'stdout': 'stdout'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.reset() == 'stdout' salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'reset', '--force'])
def test_reset(self): """ Test kuebadm.reset without parameters """ result = {"retcode": 0, "stdout": "stdout"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.reset() == "stdout" salt_mock["cmd.run_all"].assert_called_with( ["kubeadm", "reset", "--force"])
def test_reset_params(self): ''' Test kuebadm.reset with parameters ''' result = {'retcode': 0, 'stdout': 'stdout'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.reset(cert_dir='/pki', cri_socket='socket', ignore_preflight_errors='all', kubeconfig='/kube.cfg', rootfs='/mnt') == 'stdout' salt_mock['cmd.run_all'].assert_called_with([ 'kubeadm', 'reset', '--force', '--cert-dir', '/pki', '--cri-socket', 'socket', '--ignore-preflight-errors', 'all', '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt' ])