def test_config_view_error(self): ''' Test kuebadm.config_view 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.config_view()
def test_config_view_error(self): """ Test kuebadm.config_view 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.config_view()
def test_config_view(self): ''' Test kuebadm.config_view 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.config_view() == 'stdout' salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'config', 'view'])
def test_config_view(self): """ Test kuebadm.config_view 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.config_view() == "stdout" salt_mock["cmd.run_all"].assert_called_with( ["kubeadm", "config", "view"])
def test_config_view_params(self): ''' Test kuebadm.config_view 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.config_view(kubeconfig='/kube.cfg', rootfs='/mnt') == 'stdout' salt_mock['cmd.run_all'].assert_called_with([ 'kubeadm', 'config', 'view', '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt' ])
def test_config_view_params(self): """ Test kuebadm.config_view 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.config_view(kubeconfig="/kube.cfg", rootfs="/mnt") == "stdout") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "config", "view", "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])