def test_config_print_join_defaults_params(self): """ Test kuebadm.config_print_join_defaults 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_print_join_defaults( component_configs="component", kubeconfig="/kube.cfg", rootfs="/mnt") == "stdout") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "config", "print", "join-defaults", "--component-configs", "component", "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])
def test_config_print_join_defaults_error(self): ''' Test kuebadm.config_print_join_defaults 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_print_join_defaults()
def test_config_print_join_defaults_error(self): """ Test kuebadm.config_print_join_defaults 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_print_join_defaults()
def test_config_print_join_defaults(self): ''' Test kuebadm.config_print_join_defaults 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_print_join_defaults() == 'stdout' salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'config', 'print', 'join-defaults'])
def test_config_print_join_defaults(self): """ Test kuebadm.config_print_join_defaults 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_print_join_defaults() == "stdout" salt_mock["cmd.run_all"].assert_called_with( ["kubeadm", "config", "print", "join-defaults"])
def test_config_print_join_defaults_params(self): ''' Test kuebadm.config_print_join_defaults 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_print_join_defaults( component_configs='component', kubeconfig='/kube.cfg', rootfs='/mnt') == 'stdout' salt_mock['cmd.run_all'].assert_called_with([ 'kubeadm', 'config', 'print', 'join-defaults', '--component-configs', 'component', '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt' ])