# Path: papaye/tests/tools.py
# 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
# 
# class FakeGRequestResponse():
# 
#     def __init__(self, status_code, content, url="https://fake/url/"):
#         self.status_code = status_code
#         self.content = content
#         self.url = url
# 
# Path: papaye/tests/tools.py
# def mock_proxy_response(mock, response=None, side_effect=False):
#     if response is None:
#         with open(get_resource('pyramid.json'), 'rb') as pyramid_json:
#             pypi_response = FakeGRequestResponse(200, pyramid_json.read())
#         mock.return_value = pypi_response
#     else:
#         attr = 'side_effect' if side_effect else 'return_value'
#         setattr(mock, attr, response)
# 
# Path: papaye/factories/models.py
# class RootFactory(factory.Factory):
#     class Meta:
# class PackageFactory(factory.Factory):
#     class Meta:
# class ReleaseFactory(factory.Factory):
#     class Meta:
# class ReleaseFileFactory(factory.Factory):
#     class Meta:


import io
import json
import types
import unittest
from cgi import FieldStorage
from mock import patch
from pyramid import testing
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.httpexceptions import HTTPMovedPermanently
from pyramid.httpexceptions import HTTPNotFound
from pyramid.response import Response
from pyramid.threadlocal import get_current_request
from requests.exceptions import ConnectionError
from papaye.tests.tools import disable_cache, FakeGRequestResponse
from papaye.tests.tools import mock_proxy_response
from papaye.factories import models as factories
        from papaye.views.simple import ListPackagesView
        from papaye.views.simple import ListPackagesView
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import DownloadReleaseView
        from papaye.models import ReleaseFile, Release, Package
        from papaye.models import Root, Package, Release, ReleaseFile, STATUS
        from papaye.views.simple import UploadView
        from papaye.models import Root, Package, Release, ReleaseFile
        from papaye.views.simple import UploadView
        from papaye.models import Root, Package, Release, ReleaseFile
        from papaye.views.simple import UploadView
        from papaye.views.simple import ListReleaseFileByReleaseView
        from papaye.models import Package, Release, ReleaseFile
        from papaye.factories.root import repository_root_factory
        from papaye.views.simple import ListReleaseFileByReleaseView
        from papaye.models import Package, Release, ReleaseFile
        from papaye.factories.root import repository_root_factory
        from papaye.models import Root, Package, Release, ReleaseFile
        from papaye.views.simple import UploadView
    from papaye.models import User, Root
    from papaye.views.index import LoginView
    from papaye.models import User, Root
    from papaye.views.index import LoginView
    from papaye.views.simple import not_found
    from papaye.views.simple import not_found
    from papaye.views.simple import parse_matchdict
    from papaye.views.simple import parse_matchdict
    from papaye.views.simple import parse_matchdict
        factories.ReleaseFileFactory(
            filename='releasefile1.tar.gz',
            content=b'',
            md5_digest='12345',
            release=release,
        )

        self.request.matchdict['traverse'] = (package.name, release.name)
        self.request.registry.settings['papaye.proxy'] = 'true'
        view = ListReleaseFileView(package, self.request)
        pypi_result = {
            'info': {
                'name': 'package1',
            },
            'releases': {
                'release1': [{
                    'filename': 'releasefile1.tar.gz',
                    'url': 'http://example.com/',
                    'md5_digest': 'fake md5',
                }]
            }
        }
        requests_mock.return_value = FakeGRequestResponse(200, bytes(json.dumps(pypi_result), 'utf-8'))
        response = view()

        self.assertIsInstance(response, dict)

    @patch('requests.get')
    def test_list_releases_with_proxy(self, mock):


# Path: papaye/tests/tools.py
# 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
# 
# class FakeGRequestResponse():
# 
#     def __init__(self, status_code, content, url="https://fake/url/"):
#         self.status_code = status_code
#         self.content = content
#         self.url = url
# 
# Path: papaye/tests/tools.py
# def mock_proxy_response(mock, response=None, side_effect=False):
#     if response is None:
#         with open(get_resource('pyramid.json'), 'rb') as pyramid_json:
#             pypi_response = FakeGRequestResponse(200, pyramid_json.read())
#         mock.return_value = pypi_response
#     else:
#         attr = 'side_effect' if side_effect else 'return_value'
#         setattr(mock, attr, response)
# 
# Path: papaye/factories/models.py
# class RootFactory(factory.Factory):
#     class Meta:
# class PackageFactory(factory.Factory):
#     class Meta:
# class ReleaseFactory(factory.Factory):
#     class Meta:
# class ReleaseFileFactory(factory.Factory):
#     class Meta:


# Path: papaye/tests/test_views.py
import io
import json
import types
import unittest
from cgi import FieldStorage
from mock import patch
from pyramid import testing
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.httpexceptions import HTTPMovedPermanently
from pyramid.httpexceptions import HTTPNotFound
from pyramid.response import Response
from pyramid.threadlocal import get_current_request
from requests.exceptions import ConnectionError
from papaye.tests.tools import disable_cache, FakeGRequestResponse
from papaye.tests.tools import mock_proxy_response
from papaye.factories import models as factories
        from papaye.views.simple import ListPackagesView
        from papaye.views.simple import ListPackagesView
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile
        from papaye.views.simple import DownloadReleaseView
        from papaye.models import ReleaseFile, Release, Package
        from papaye.models import Root, Package, Release, ReleaseFile, STATUS
        from papaye.views.simple import UploadView
        from papaye.models import Root, Package, Release, ReleaseFile
        from papaye.views.simple import UploadView
        from papaye.models import Root, Package, Release, ReleaseFile
        from papaye.views.simple import UploadView
        from papaye.views.simple import ListReleaseFileByReleaseView
        from papaye.models import Package, Release, ReleaseFile
        from papaye.factories.root import repository_root_factory
        from papaye.views.simple import ListReleaseFileByReleaseView
        from papaye.models import Package, Release, ReleaseFile
        from papaye.factories.root import repository_root_factory
        from papaye.models import Root, Package, Release, ReleaseFile
        from papaye.views.simple import UploadView
    from papaye.models import User, Root
    from papaye.views.index import LoginView
    from papaye.models import User, Root
    from papaye.views.index import LoginView
    from papaye.views.simple import not_found
    from papaye.views.simple import not_found
    from papaye.views.simple import parse_matchdict
    from papaye.views.simple import parse_matchdict
    from papaye.views.simple import parse_matchdict

        factories.ReleaseFileFactory(
            filename='releasefile1.tar.gz',
            content=b'',
            md5_digest='12345',
            release=release,
        )

        self.request.matchdict['traverse'] = (package.name, release.name)
        self.request.registry.settings['papaye.proxy'] = 'true'
        view = ListReleaseFileView(package, self.request)
        pypi_result = {
            'info': {
                'name': 'package1',
            },
            'releases': {
                'release1': [{
                    'filename': 'releasefile1.tar.gz',
                    'url': 'http://example.com/',
                    'md5_digest': 'fake md5',
                }]
            }
        }
        requests_mock.return_value = FakeGRequestResponse(200, bytes(json.dumps(pypi_result), 'utf-8'))
        response = view()

        self.assertIsInstance(response, dict)

    @patch('requests.get')
    def test_list_releases_with_proxy(self, mock):


        mock_proxy_response(mock)