예제 #1
0
def test_main_with_config(rabbit_config, tmpdir):

    config = tmpdir.join('config.yaml')
    config.write("""
        WEB_SERVER_ADDRESS: '0.0.0.0:8001'
        AMQP_URI: '{}'
        serializer: 'json'
    """.format(rabbit_config[AMQP_URI_CONFIG_KEY]))

    parser = setup_parser()
    args = parser.parse_args([
        'run',
        '--config',
        config.strpath,
        'test.sample',
    ])

    with patch('nameko.cli.run.run') as run:
        main(args)
        assert run.call_count == 1
        (_, config) = run.call_args[0]

        assert config == {
            WEB_SERVER_CONFIG_KEY: '0.0.0.0:8001',
            AMQP_URI_CONFIG_KEY: rabbit_config[AMQP_URI_CONFIG_KEY],
            SERIALIZER_CONFIG_KEY: 'json'
        }
예제 #2
0
    def handle(self, *args, **options):
        AMQP_URI = 'pyamqp://*****:*****@172.17.0.5'
        parser = argparse.ArgumentParser()
        parser.add_argument(
            'services',
            nargs='+',
            metavar='module[:service class]',
            help='python path to one or more service classes to run')
        parser.add_argument('--config',
                            default='',
                            help='The YAML configuration file')
        parser.add_argument('--broker',
                            default='pyamqp://*****:*****@localhost',
                            help='RabbitMQ broker url')
        parser.add_argument(
            '--backdoor-port',
            type=int,
            help='Specify a port number to host a backdoor, which can be'
            ' connected to for an interactive interpreter within the running'
            ' service process using `nameko backdoor`.')
        if not hasattr(settings, 'MICROFRAMEWORK_SERVICE_CLASS'):
            log.error(
                'You need to define MICROFRAMEWORK_SERVICE_CLASS in django settings'
            )
            return False
        args = parser.parse_args(
            ["--broker", AMQP_URI, "example.service:ListenerService"])

        run.main(args)
예제 #3
0
def test_main_with_config(rabbit_config, tmpdir):

    config = tmpdir.join('config.yaml')
    config.write("""
        WEB_SERVER_ADDRESS: '0.0.0.0:8001'
        AMQP_URI: '{}'
        serializer: 'json'
    """.format(rabbit_config[AMQP_URI_CONFIG_KEY]))

    parser = setup_parser()
    args = parser.parse_args([
        'run',
        '--config',
        config.strpath,
        'test.sample',
    ])

    with patch('nameko.cli.run.run') as run:
        main(args)
        assert run.call_count == 1
        (_, config) = run.call_args[0]

        assert config == {
            WEB_SERVER_CONFIG_KEY: '0.0.0.0:8001',
            AMQP_URI_CONFIG_KEY: rabbit_config[AMQP_URI_CONFIG_KEY],
            SERIALIZER_CONFIG_KEY: 'json'
        }
예제 #4
0
파일: test_run.py 프로젝트: jkal/nameko
def test_main_with_config(rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'run',
        '--config',
        RUN_CONFIG_FILE,
        'test.sample',
    ])

    with patch('nameko.cli.run.run') as run:
        main(args)
        assert run.call_count == 1
        (_, config) = run.call_args[0]

        assert config == {
            'WEB_SERVER_ADDRESS': '0.0.0.0:8001',
            'AMQP_URI': 'amqp://*****:*****@example.org'
        }
예제 #5
0
def test_main_with_config(rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'run',
        '--config',
        RUN_CONFIG_FILE,
        'test.sample',
    ])

    with patch('nameko.cli.run.run') as run:
        main(args)
        assert run.call_count == 1
        (_, config) = run.call_args[0]

        assert config == {
            'WEB_SERVER_ADDRESS': '0.0.0.0:8001',
            'AMQP_URI': 'amqp://*****:*****@example.org'
        }
예제 #6
0
def test_main_with_config(rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'run',
        '--config',
        TEST_CONFIG_FILE,
        'test.sample',
    ])

    with patch('nameko.cli.run.run') as run:
        main(args)
        assert run.call_count == 1
        (_, config) = run.call_args[0]

        assert config == {
            WEB_SERVER_CONFIG_KEY: '0.0.0.0:8001',
            AMQP_URI_CONFIG_KEY: 'amqp://*****:*****@localhost',
            SERIALIZER_CONFIG_KEY: 'json'
        }
예제 #7
0
파일: test_run.py 프로젝트: Costeijn/nameko
def test_main_with_config(rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'run',
        '--config',
        TEST_CONFIG_FILE,
        'test.sample',
    ])

    with patch('nameko.cli.run.run') as run:
        main(args)
        assert run.call_count == 1
        (_, config) = run.call_args[0]

        assert config == {
            WEB_SERVER_CONFIG_KEY: '0.0.0.0:8001',
            AMQP_URI_CONFIG_KEY: 'amqp://*****:*****@localhost',
            SERIALIZER_CONFIG_KEY: 'json'
        }
예제 #8
0
import argparse
from nameko.cli.run import main
AMQP_URI = 'pyamqp://*****:*****@172.17.0.5'
parser = argparse.ArgumentParser()
parser.add_argument(
    'services', nargs='+',
    metavar='module[:service class]',
    help='python path to one or more service classes to run')
parser.add_argument(
    '--config', default='',
    help='The YAML configuration file')
parser.add_argument(
    '--broker', default='pyamqp://*****:*****@localhost',
    help='RabbitMQ broker url')
parser.add_argument(
    '--backdoor-port', type=int,
    help='Specify a port number to host a backdoor, which can be'
         ' connected to for an interactive interpreter within the running'
         ' service process using `nameko backdoor`.')

args = parser.parse_args(["--broker", AMQP_URI, "service.service:ListenerService"])
main(args)