def test_config_images_list_params(self): """ Test kuebadm.config_images_list with parameters """ result = {"retcode": 0, "stdout": "image1\nimage2\n"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.config_images_list( config="/kubeadm.cfg", feature_gates="k=v", kubernetes_version="version", kubeconfig="/kube.cfg", rootfs="/mnt", ) == ["image1", "image2"] salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "config", "images", "list", "--config", "/kubeadm.cfg", "--feature-gates", "k=v", "--kubernetes-version", "version", "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])
def test_config_images_list_error(self): ''' Test kuebadm.config_images_list 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_images_list()
def test_config_images_list_error(self): """ Test kuebadm.config_images_list 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_images_list()
def test_config_images_list(self): ''' Test kuebadm.config_images_list without parameters ''' result = {'retcode': 0, 'stdout': 'image1\nimage2\n'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.config_images_list() == ['image1', 'image2'] salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'config', 'images', 'list'])
def test_config_images_list(self): """ Test kuebadm.config_images_list without parameters """ result = {"retcode": 0, "stdout": "image1\nimage2\n"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.config_images_list() == ["image1", "image2"] salt_mock["cmd.run_all"].assert_called_with( ["kubeadm", "config", "images", "list"])
def test_config_images_list_params(self): ''' Test kuebadm.config_images_list with parameters ''' result = {'retcode': 0, 'stdout': 'image1\nimage2\n'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.config_images_list( config='/kubeadm.cfg', feature_gates='k=v', kubernetes_version='version', kubeconfig='/kube.cfg', rootfs='/mnt') == ['image1', 'image2'] salt_mock['cmd.run_all'].assert_called_with([ 'kubeadm', 'config', 'images', 'list', '--config', '/kubeadm.cfg', '--feature-gates', 'k=v', '--kubernetes-version', 'version', '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt' ])