# Path: fedoracommunity/search/index.py
# MAX_RETRY = 10
# def download_file(url, dest):
#     def __init__(self, cache_path,
#                  bodhi_url=None,
#                  mdapi_url=None,
#                  icons_url=None,
#                  pdc_url=None,
#                  pagure_url=None):
#     def _call_api(self, url):
#     def create_index(self):
#     def _get_active_fedora_releases(self):
#     def pull_icons(self):
#     def cache_icons(self):
#     def gather_pdc_packages(self, pkg_name=None):
#     def latest_active(self, name, ignore=None):
#     def construct_package_dictionary(self, package):
#     def get_sub_packages(self, package):
#     def index_files_of_interest(self, doc, package_dict):
#     def index_packages(self):
#         def io_work(package):
#     def _create_document(self, package, old_doc=None):
# def run(cache_path, bodhi_url=None,
#         mdapi_url=None, icons_url=None, pdc_url=None, pagure_url=None):
# class Indexer(object):


import json
import os
import pytest
import xapian
from fedoracommunity.search import index
    flags = xapian.QueryParser.FLAG_DEFAULT | \
        xapian.QueryParser.FLAG_PARTIAL | \
        xapian.QueryParser.FLAG_WILDCARD
    query = qp.parse_query(query, flags)

    enquire.set_query(query)
    matches = enquire.get_mset(0, 10)

    results = []
    for m in matches:
        results.append(json.loads(m.document.get_data()))

    return results


@pytest.fixture(scope='module')
def indexer():
    """ Helper fixture that create an indexer for
    the xapian db
    """
    indexer = index.Indexer('/tmp/xapian/')
    return indexer


def test_Indexer_create_index(delete_xapian_db):
    """ Test the _create_index method
    We create a xapian db that is used after by the other
    test
    """
    assert os.path.isdir('/tmp/xapian/search') is False

# Path: fedoracommunity/search/index.py
# MAX_RETRY = 10
# def download_file(url, dest):
#     def __init__(self, cache_path,
#                  bodhi_url=None,
#                  mdapi_url=None,
#                  icons_url=None,
#                  pdc_url=None,
#                  pagure_url=None):
#     def _call_api(self, url):
#     def create_index(self):
#     def _get_active_fedora_releases(self):
#     def pull_icons(self):
#     def cache_icons(self):
#     def gather_pdc_packages(self, pkg_name=None):
#     def latest_active(self, name, ignore=None):
#     def construct_package_dictionary(self, package):
#     def get_sub_packages(self, package):
#     def index_files_of_interest(self, doc, package_dict):
#     def index_packages(self):
#         def io_work(package):
#     def _create_document(self, package, old_doc=None):
# def run(cache_path, bodhi_url=None,
#         mdapi_url=None, icons_url=None, pdc_url=None, pagure_url=None):
# class Indexer(object):


# Path: tests/test_indexer.py
import json
import os
import pytest
import xapian
from fedoracommunity.search import index

    flags = xapian.QueryParser.FLAG_DEFAULT | \
        xapian.QueryParser.FLAG_PARTIAL | \
        xapian.QueryParser.FLAG_WILDCARD
    query = qp.parse_query(query, flags)

    enquire.set_query(query)
    matches = enquire.get_mset(0, 10)

    results = []
    for m in matches:
        results.append(json.loads(m.document.get_data()))

    return results


@pytest.fixture(scope='module')
def indexer():
    """ Helper fixture that create an indexer for
    the xapian db
    """
    indexer = index.Indexer('/tmp/xapian/')
    return indexer


def test_Indexer_create_index(delete_xapian_db):
    """ Test the _create_index method
    We create a xapian db that is used after by the other
    test
    """
    assert os.path.isdir('/tmp/xapian/search') is False

    index.Indexer('/tmp/xapian/')