コード例 #1
0
def test_get_service_config__service_name_dne_and_throws_error_case():
    """
    Self Explanitory...
    """
    inline = InlineServices()

    with pytest.raises(ValueError):
        inline.get_service_config('requester')
コード例 #2
0
def test_get_service_config__happy_case():
    """
    Self Explanitory...
    """
    inline = InlineServices()
    inline.set_main_service('requester', REQUESTER_PATH)

    config = inline.get_service_config('requester')
    assert 'num_req_to_send' in config
コード例 #3
0
def test_inline_services__services_can_be_run_with_paths():
    """
    Make sure that services can be run together with inline services
    provided via paths.
    """
    inline = InlineServices()
    inline.set_main_service('requester', REQUESTER_PATH)
    inline.add_service('replyer', REPLYER_PATH)
    inline.add_relation('requester', 'request', 'replyer', 'reply')
    inline.start()

    req_config = inline.get_service_config('requester')
    assert len(req_config['responses_recieved']) == 2
コード例 #4
0
def test_inline_services__main_by_path_can_have_provided_config():
    """
    Make sure that services, when run by path, can have a pre-existing
    config provided.
    """
    inline = InlineServices()
    inline.set_main_service('requester', REQUESTER_PATH, REQUESTER_CONFIG)
    inline.add_service('replyer', REPLYER_PATH)
    inline.add_relation('requester', 'request', 'replyer', 'reply')
    inline.start()

    req_config = inline.get_service_config('requester')
    assert len(req_config['responses_recieved']) == 4
コード例 #5
0
def test_inline_services__service_calls_multiple_relations():
    """
    Make sure that one main service can call multiple dependent services.
    """
    inline = InlineServices()
    inline.set_main_service('multi_requester', MULTI_REQUESTER_PATH)
    inline.add_service('replyer_1', REPLYER_PATH)
    inline.add_relation('multi_requester', 'request_1', 'replyer_1', 'reply')
    inline.add_service('replyer_2', REPLYER_PATH)
    inline.add_relation('multi_requester', 'request_2', 'replyer_2', 'reply')
    inline.start()

    req_config = inline.get_service_config('multi_requester')
    assert len(req_config['responses_recieved']) == 4
コード例 #6
0
def test_inline_services__services_can_be_run_with_imported_modules():
    """
    Make sure that services can be run together with inline services
    provided via modules.
    """
    inline = InlineServices()
    inline.set_main_service_by_module(
        'requester', import_python_file_from_cwd(REQUESTER_PATH))
    inline.add_service_by_module('replyer',
                                 import_python_file_from_cwd(REPLYER_PATH))
    inline.add_relation('requester', 'request', 'replyer', 'reply')
    inline.start()

    req_config = inline.get_service_config('requester')
    assert len(req_config['responses_recieved']) == 2
コード例 #7
0
def test_inline_services__main_by_module_can_have_provided_config():
    """
    Make sure that a main service, by module, can have a provided
    config.
    """
    inline = InlineServices()
    inline.set_main_service_by_module(
        'requester', import_python_file_from_cwd(REQUESTER_PATH),
        REQUESTER_CONFIG)
    inline.add_service_by_module(
        'replyer',
        import_python_file_from_cwd(REPLYER_PATH),
    )
    inline.add_relation('requester', 'request', 'replyer', 'reply')
    inline.start()

    req_config = inline.get_service_config('requester')
    assert len(req_config['responses_recieved']) == 4