예제 #1
0
def test_init_indices(elastic):
    search = Search(Config.from_env())
    assert elastic.indices.call_count == 3

    # Should take no action if called again
    search.init_indices()
    assert elastic.indices.call_count == 3
예제 #2
0
def search(args):
    config = Config.from_env()
    factory = DugFactory(config)
    dug = Dug(factory)
    # dug = Dug()
    response = dug.search(args.target, args.query, **args.kwargs)

    print(response)
예제 #3
0
def test_update_doc(elastic: MockElastic):
    search = Search(Config.from_env())

    search.index_doc('concepts_index', {'name': 'sample'}, "ID:1")
    search.update_doc('concepts_index', {'name': 'new value!'}, "ID:1")
    assert elastic.indices.get_index('concepts_index').get("ID:1") == {
        'name': 'new value!'
    }
예제 #4
0
def search(args):
    config = Config.from_env()
    factory = DugFactory(config)
    dug = Dug(factory)
    # dug = Dug()
    response = dug.search(args.target, args.query, **args.kwargs)
    jsonResponse = json.dumps(response, indent = 2)
    print(jsonResponse)
예제 #5
0
def crawl(args):
    config = Config.from_env()
    if not args.extract_dug_elements:
        # disable extraction
        config.node_to_element_queries = {}
    factory = DugFactory(config)
    dug = Dug(factory)
    dug.crawl(args.target, args.parser_type, args.element_type)
예제 #6
0
def test_index_doc(elastic: MockElastic):
    search = Search(Config.from_env())

    assert len(elastic.indices.get_index('concepts_index').values) == 0
    search.index_doc('concepts_index', {'name': 'sample'}, "ID:1")
    assert len(elastic.indices.get_index('concepts_index').values) == 1
    assert elastic.indices.get_index('concepts_index').get("ID:1") == {
        'name': 'sample'
    }
예제 #7
0
def test_init(elastic):
    cfg = Config(elastic_host='localhost',
                 elastic_username='******',
                 elastic_password='******',
                 nboost_host='localhost')

    search = Search(cfg)

    assert search.indices == default_indices
    assert search.hosts == hosts
    assert search.es is elastic
예제 #8
0
def datatypes(args):
    config = Config.from_env()
    factory = DugFactory(config)
    dug = Dug(factory)
    # dug = Dug()
    response = dug.info(args.target, **args.kwargs)
예제 #9
0
def crawl(args):
    config = Config.from_env()
    factory = DugFactory(config)
    dug = Dug(factory)
    dug.crawl(args.target, args.parser_type, args.element_type)
예제 #10
0
def test_annotator_init():
    cfg = Config.from_env()
    url = cfg.annotator["url"]

    annotator = Annotator(**cfg.annotator)
    assert annotator.url == url
예제 #11
0
def dug ():
    if not hasattr(g, 'dug'):
        g.search = Search(Config.from_env())
    return g.search
예제 #12
0
def test_search_init():
    """
    Tests if we can create a Search instance without it blowing up :D
    """
    Search(cfg=Config.from_env())
예제 #13
0
def test_config_created_from_env_vars():
    cfg = Config.from_env()

    assert cfg.elastic_password == "ohwhoa"
    assert cfg.redis_password == "thatsprettyneat"
    assert cfg.nboost_host == "gettinboosted!"
예제 #14
0
def test_init_no_ping(elastic):
    elastic.disconnect()
    with pytest.raises(SearchException):
        _search = Search(Config.from_env())