def test_token_create_params(self): ''' Test kuebadm.token_create with parameters ''' result = {'retcode': 0, 'stdout': 'token'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_create(token='token', config='/kubeadm.cfg', description='a description', groups=['g:1', 'g:2'], ttl='1h1m1s', usages=['u1', 'u2'], kubeconfig='/kube.cfg', rootfs='/mnt') == 'token' salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'token', 'create', 'token', '--config', '/kubeadm.cfg', '--description', 'a description', '--groups', '["g:1", "g:2"]', '--ttl', '1h1m1s', '--usages', '["u1", "u2"]', '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt'])
def test_token_create_error(self): ''' Test kuebadm.token_create 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_create()
def test_token_create_error(self): """ Test kuebadm.token_create 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_create()
def test_token_create(self): ''' Test kuebadm.token_create without parameters ''' result = {'retcode': 0, 'stdout': 'token'} salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_create() == 'token' salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'token', 'create'])
def test_token_create(self): """ Test kuebadm.token_create without parameters """ result = {"retcode": 0, "stdout": "token"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert kubeadm.token_create() == "token" salt_mock["cmd.run_all"].assert_called_with( ["kubeadm", "token", "create"])
def test_token_create_params(self): """ Test kuebadm.token_create with parameters """ result = {"retcode": 0, "stdout": "token"} salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(kubeadm.__salt__, salt_mock): assert (kubeadm.token_create( token="token", config="/kubeadm.cfg", description="a description", groups=["g:1", "g:2"], ttl="1h1m1s", usages=["u1", "u2"], kubeconfig="/kube.cfg", rootfs="/mnt", ) == "token") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "token", "create", "token", "--config", "/kubeadm.cfg", "--description", "a description", "--groups", '["g:1", "g:2"]', "--ttl", "1h1m1s", "--usages", '["u1", "u2"]', "--kubeconfig", "/kube.cfg", "--rootfs", "/mnt", ])