def test_token_delete_error(self): ''' Test kuebadm.token_delete 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.token_delete('token')
def test_token_delete_error(self): """ Test kuebadm.token_delete 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.token_delete("token")
def test_token_delete(self): ''' Test kuebadm.token_delete without parameters ''' result = {'retcode': 0, 'stdout': 'deleted'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_delete('token') salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'token', 'delete', 'token'])
def test_token_delete(self): """ Test kuebadm.token_delete without parameters """ result = {"retcode": 0, "stdout": "deleted"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_delete("token") salt_mock["cmd.run_all"].assert_called_with( ["kubeadm", "token", "delete", "token"])
def test_token_delete_params(self): ''' Test kuebadm.token_delete with parameters ''' result = {'retcode': 0, 'stdout': 'deleted'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_delete('token', kubeconfig='/kube.cfg', rootfs='/mnt') salt_mock['cmd.run_all'].assert_called_with([ 'kubeadm', 'token', 'delete', 'token', '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt' ])
def test_token_delete_params(self): """ Test kuebadm.token_delete with parameters """ result = {"retcode": 0, "stdout": "deleted"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_delete("token", kubeconfig="/kube.cfg", rootfs="/mnt") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "token", "delete", "token", "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])