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
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)
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!' }
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)
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)
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' }
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
def datatypes(args): config = Config.from_env() factory = DugFactory(config) dug = Dug(factory) # dug = Dug() response = dug.info(args.target, **args.kwargs)
def crawl(args): config = Config.from_env() factory = DugFactory(config) dug = Dug(factory) dug.crawl(args.target, args.parser_type, args.element_type)
def test_annotator_init(): cfg = Config.from_env() url = cfg.annotator["url"] annotator = Annotator(**cfg.annotator) assert annotator.url == url
def dug (): if not hasattr(g, 'dug'): g.search = Search(Config.from_env()) return g.search
def test_search_init(): """ Tests if we can create a Search instance without it blowing up :D """ Search(cfg=Config.from_env())
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!"
def test_init_no_ping(elastic): elastic.disconnect() with pytest.raises(SearchException): _search = Search(Config.from_env())