Пример #1
0
def test_cdxserver_config():
    config = yaml.load(yaml_config)
    cdxserver = create_cdx_server(config.get('test_1'))
    assert(isinstance(cdxserver, CDXServer))
    sources = cdxserver.sources
    assert len(sources) == 5

    assert type(sources[0]) == CDXFile
    assert sources[0].filename.endswith('example.cdx')

    # remote source with no remote processing
    assert type(sources[1]) == RemoteCDXSource
    assert sources[1].remote_url == 'http://cdxserver.example.com/cdx'
    assert sources[1].remote_processing == False

    # remote cdx server with processing
    assert type(sources[2]) == RemoteCDXSource
    assert sources[2].remote_url == 'http://cdxserver.example.com/cdx'
    assert sources[2].remote_processing == True

    # redis source
    assert type(sources[3]) == RedisCDXSource
    assert sources[3].redis_url == 'redis://redis.example.com:6379/0'

    assert type(sources[4]) == ZipNumCluster
    assert sources[4].summary.endswith('zipnum-sample.idx')
    assert sources[4].loc_resolver.loc_filename.endswith('zipnum-sample.loc')
Пример #2
0
def test_single_cdx():
    config = yaml.load(yaml_config)
    cdxserver = create_cdx_server(config.get('test_5'))
    assert(isinstance(cdxserver, CDXServer))
    sources = cdxserver.sources
    assert len(sources) == 1

    assert type(sources[0]) == CDXFile
    assert sources[0].filename.endswith('example.cdx')
Пример #3
0
def assert_remote_cdxserver(config_name):
    config = yaml.load(yaml_config)
    cdxserver = create_cdx_server(config.get(config_name))
    assert(isinstance(cdxserver, RemoteCDXServer))

    source = cdxserver.source

    # remote cdx server with remote processing
    assert type(source) == RemoteCDXSource
    assert source.remote_url == 'http://cdxserver.example.com/cdx'
    assert source.remote_processing == True
Пример #4
0
    def init_from_config(config,
                         ds_rules_file=DEFAULT_RULES_FILE,
                         html_view=None,
                         server_cls=None):

        perms_policy = None

        if hasattr(config, 'get'):
            perms_policy = config.get('perms_policy')
            server_cls = config.get('server_cls', server_cls)

        cdx_server = create_cdx_server(config, ds_rules_file, server_cls)

        return QueryHandler(cdx_server, html_view, perms_policy)
Пример #5
0
    def init_from_config(config,
                         ds_rules_file=DEFAULT_RULES_FILE,
                         html_view=None,
                         server_cls=None):

        perms_policy = None

        if hasattr(config, 'get'):
            perms_policy = config.get('perms_policy')
            server_cls = config.get('server_cls', server_cls)

        cdx_server = create_cdx_server(config, ds_rules_file, server_cls)

        return QueryHandler(cdx_server, html_view, perms_policy)
Пример #6
0
def test_invalid_config():
    config = yaml.load(yaml_config)
    cdxserver = create_cdx_server(config.get('test_6'))
    assert(isinstance(cdxserver, CDXServer))
    sources = cdxserver.sources
    assert len(sources) == 0