# 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/tools.py
# 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)


import unittest
from mock import patch
from pyramid.threadlocal import get_current_request
from requests.exceptions import ConnectionError
from papaye.factories import models as factories
from papaye.tests.tools import FakeGRequestResponse
from papaye.tests.tools import mock_proxy_response
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.factories.root import repository_root_factory
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import smart_merge
        from papaye.factories.root import repository_root_factory
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import smart_merge
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.proxy import clone
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import clone
        from papaye.models import Package, Release, ReleaseFile




class ProxyTest(unittest.TestCase):

    def setUp(self):
        self.request = get_current_request()

    @patch('requests.get')
    def test_get_remote_informations(self, mock):
        # Given
        mock_proxy_response(mock)
        url = "http://pypi.python.org/pypi/pyramid/json"
        proxy = PyPiProxy()

        # When
        result = proxy.get_remote_informations(url)

        # Then
        self.assertIsInstance(result, dict)
        self.assertEqual(result['info']['name'], 'pyramid')

    @patch('requests.get')
    def test_get_remote_informations_404(self, mock):
        # Given

# 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/tools.py
# 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/tests/test_proxy.py
import unittest
from mock import patch
from pyramid.threadlocal import get_current_request
from requests.exceptions import ConnectionError
from papaye.factories import models as factories
from papaye.tests.tools import FakeGRequestResponse
from papaye.tests.tools import mock_proxy_response
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.factories.root import repository_root_factory
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import smart_merge
        from papaye.factories.root import repository_root_factory
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import smart_merge
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import smart_merge
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        from papaye.proxy import clone
        from papaye.models import Package, Release, ReleaseFile
        from papaye.proxy import clone
        from papaye.models import Package, Release, ReleaseFile





class ProxyTest(unittest.TestCase):

    def setUp(self):
        self.request = get_current_request()

    @patch('requests.get')
    def test_get_remote_informations(self, mock):
        # Given
        mock_proxy_response(mock)
        url = "http://pypi.python.org/pypi/pyramid/json"
        proxy = PyPiProxy()

        # When
        result = proxy.get_remote_informations(url)

        # Then
        self.assertIsInstance(result, dict)
        self.assertEqual(result['info']['name'], 'pyramid')

    @patch('requests.get')
    def test_get_remote_informations_404(self, mock):
        # Given

        mock.return_value = FakeGRequestResponse(404, b'')