# Path: papaye/tests/tools.py
# def set_database_connection(request, blob_dir=None, config=None):
#     if not blob_dir:
#         blob_dir = tempfile.mkdtemp('blobs')
#     conn = get_db_connection(blob_dir)
#     request._primary_zodb_conn = conn
#     if config:
#         import transaction
#         conn.root()['repository'] = {}
#         conn.root()['user'] = {}
#         transaction.commit()
#         config.registry._zodb_databases = {'': conn._db}
#     return blob_dir
# 
# def disable_cache(settings=None):
#     cache_settings = {
#         'cache.regions': 'pypi',
#         'cache.enabled': 'false',
#     }
#     if settings:
#         settings.update(cache_settings)
#     else:
#         settings = cache_settings
#     set_cache_regions_from_settings(settings)
#     return settings


import contextlib
import os
import pytest
import shutil
from pyramid import testing
from pyramid.interfaces import ISettings
from papaye.tests.tools import set_database_connection, disable_cache
        '/simple/*traverse',
        factory='papaye.factories.root:repository_root_factory'
    )


@pytest.fixture
def request_factory(*args, **kwargs):
    def build_request(*args, **kwargs):
        request = testing.DummyRequest(*args, **kwargs)
        return request
    return build_request


@pytest.fixture
def config_factory(*args, **kwargs):
    def build_configurator(*args, **kwargs):
        return testing.setUp(*args, **kwargs)
    return build_configurator


@pytest.fixture
def repo_configuration(request, request_factory, tmpdir, config_factory):
    settings = disable_cache()
    settings.update({
        'papaye.proxy': False,
        'papaye.packages_directory': tmpdir.strpath,
        'pyramid.incluces': 'pyramid_zodbconn',
    })
#     req = testing.DummyRequest()
    req = request_factory(matched_route=FakeRoute('simple'))

# Path: papaye/tests/tools.py
# def set_database_connection(request, blob_dir=None, config=None):
#     if not blob_dir:
#         blob_dir = tempfile.mkdtemp('blobs')
#     conn = get_db_connection(blob_dir)
#     request._primary_zodb_conn = conn
#     if config:
#         import transaction
#         conn.root()['repository'] = {}
#         conn.root()['user'] = {}
#         transaction.commit()
#         config.registry._zodb_databases = {'': conn._db}
#     return blob_dir
# 
# def disable_cache(settings=None):
#     cache_settings = {
#         'cache.regions': 'pypi',
#         'cache.enabled': 'false',
#     }
#     if settings:
#         settings.update(cache_settings)
#     else:
#         settings = cache_settings
#     set_cache_regions_from_settings(settings)
#     return settings


# Path: papaye/conftest.py
import contextlib
import os
import pytest
import shutil
from pyramid import testing
from pyramid.interfaces import ISettings
from papaye.tests.tools import set_database_connection, disable_cache

        '/simple/*traverse',
        factory='papaye.factories.root:repository_root_factory'
    )


@pytest.fixture
def request_factory(*args, **kwargs):
    def build_request(*args, **kwargs):
        request = testing.DummyRequest(*args, **kwargs)
        return request
    return build_request


@pytest.fixture
def config_factory(*args, **kwargs):
    def build_configurator(*args, **kwargs):
        return testing.setUp(*args, **kwargs)
    return build_configurator


@pytest.fixture
def repo_configuration(request, request_factory, tmpdir, config_factory):
    settings = disable_cache()
    settings.update({
        'papaye.proxy': False,
        'papaye.packages_directory': tmpdir.strpath,
        'pyramid.incluces': 'pyramid_zodbconn',
    })
#     req = testing.DummyRequest()
    req = request_factory(matched_route=FakeRoute('simple'))

    set_database_connection(req)