예제 #1
0
 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",
         ])
예제 #2
0
 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()
예제 #3
0
 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()
예제 #4
0
 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'])
예제 #5
0
 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"])
예제 #6
0
 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'
         ])