def test_plain_fallback(pystartup): parser = setup_parser() args = parser.parse_args(['shell', '--interface', 'bpython']) with patch('nameko.cli.shell.code') as code: main(args) _, kwargs = code.interact.call_args local = kwargs['local'] assert 'n' in local.keys() assert local['foo'] == 42 local['n'].disconnect()
def test_ipython(pystartup): parser = setup_parser() args = parser.parse_args(['shell', '--interface', 'ipython']) with patch('IPython.embed') as embed: main(args) _, kwargs = embed.call_args local = kwargs['user_ns'] assert 'n' in local.keys() assert local['foo'] == 42 local['n'].disconnect()
def test_config(pystartup): parser = setup_parser() args = parser.parse_args(['shell', '--config', TEST_CONFIG_FILE]) with patch('nameko.cli.shell.code') as code: main(args) _, kwargs = code.interact.call_args local = kwargs['local'] assert 'n' in local.keys() assert local['n'].config == { WEB_SERVER_CONFIG_KEY: '0.0.0.0:8001', AMQP_URI_CONFIG_KEY: 'amqp://*****:*****@localhost', SERIALIZER_CONFIG_KEY: 'json' } local['n'].disconnect()
def test_basic(tmpdir): parser = setup_parser() args = parser.parse_args(['shell']) startup = tmpdir.join('startup.py') startup.write('foo = 42') with patch('nameko.cli.shell.os.environ') as environ: environ.get.return_value = str(startup) with patch('nameko.cli.shell.code') as code: main(args) _, kwargs = code.interact.call_args local = kwargs['local'] assert 'n' in local.keys() assert local['foo'] == 42 local['n'].disconnect()