Ejemplo n.º 1
0
 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",
         ])
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 4
0
 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'])
Ejemplo n.º 5
0
 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"])
Ejemplo n.º 6
0
 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'
         ])