def test_config_migrate_params(self): """ Test kuebadm.config_migrate 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_migrate( "/oldconfig.cfg", new_config="/newconfig.cfg", kubeconfig="/kube.cfg", rootfs="/mnt", ) == "stdout") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "config", "migrate", "--old-config", "/oldconfig.cfg", "--new-config", "/newconfig.cfg", "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])
def test_config_migrate_error(self): ''' Test kuebadm.config_migrate 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_migrate('/oldconfig.cfg')
def test_config_migrate_error(self): """ Test kuebadm.config_migrate 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_migrate("/oldconfig.cfg")
def test_config_migrate(self): ''' Test kuebadm.config_migrate 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_migrate('/oldconfig.cfg') == 'stdout' salt_mock['cmd.run_all'].assert_called_with([ 'kubeadm', 'config', 'migrate', '--old-config', '/oldconfig.cfg' ])
def test_config_migrate(self): """ Test kuebadm.config_migrate 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_migrate("/oldconfig.cfg") == "stdout" salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "config", "migrate", "--old-config", "/oldconfig.cfg" ])