Esempio n. 1
0
    def test_get_remote_informations(self, mock):
        from papaye.proxy import PyPiProxy
        mock_proxy_response(mock)
        url = "http://pypi.python.org/pypi/pyramid/json"

        proxy = PyPiProxy()
        result = proxy.get_remote_informations(url)
        self.assertIsInstance(result, dict)
        self.assertEqual(result['info']['name'], 'pyramid')
Esempio n. 2
0
    def test_build_remote_repository_with_release_name(self, mock):
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        mock_proxy_response(mock)
        proxy = PyPiProxy()

        result = proxy.build_remote_repository('pyramid', release_name='1.5')

        assert isinstance(result, Root)
        assert 'pyramid' in list(result.keys())
        assert len(list(result['pyramid'])) == 1
Esempio n. 3
0
    def test_build_remote_repository(self, mock):
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        mock_proxy_response(mock)
        proxy = PyPiProxy()

        result = proxy.build_remote_repository('pyramid')

        assert isinstance(result, Root)
        assert 'pyramid' in [e.__name__ for e in result]
        assert len(list(result['pyramid'])) == 81
        assert not hasattr(list(result['pyramid'])[0], 'metadata')
Esempio n. 4
0
    def test_build_remote_repository_with_metadata(self, mock):
        from papaye.models import Root
        from papaye.proxy import PyPiProxy
        mock_proxy_response(mock)
        proxy = PyPiProxy()

        result = proxy.build_remote_repository('pyramid', metadata=True)

        assert isinstance(result, Root)
        assert 'pyramid' in list(result.keys())
        assert len(list(result['pyramid'])) == 81
        assert hasattr(list(result['pyramid'])[0], 'metadata')
        assert len(list(result['pyramid'])[0].metadata.keys()) == 13
Esempio n. 5
0
    def test_merged_repository_with_release_name(self, mock):
        from papaye.models import Package, Release, ReleaseFile, Root
        from papaye.proxy import PyPiProxy
        mock_proxy_response(mock)
        package1 = Package(name='pyramid')
        package1['100.5'] = Release(version='100.5', metadata={})
        package1['100.5']['pyramid-100.5.tar.gz'] = ReleaseFile(
            filename='pyramid-100.5.tar.gz',
            content=b'a existing content',
            md5_digest='12345'
        )
        proxy = PyPiProxy()
        result = proxy.merged_repository(package1, release_name='1.5')

        assert isinstance(result, Root)
        assert [pack.__name__ for pack in result] == ["pyramid", ]
        assert len(list(result['pyramid'])) == 2
        assert '1.5' in result['pyramid'].releases.keys()
        assert '100.5' in [rel for rel in result['pyramid'].releases]
Esempio n. 6
0
    def test_list_releases_with_proxy(self, mock):
        from papaye.views.simple import ListReleaseFileView
        from papaye.models import Package, Release, Root, ReleaseFile

        mock_proxy_response(mock)

        # Test packages
        root = Root()
        root["pyramid"] = Package(name="pyramid")
        root["pyramid"]["release1"] = Release(name="release1", version="1.0", metadata={})
        root["pyramid"]["release1"].__parent__ = root["pyramid"]
        root["pyramid"]["release1"]["releasefile1.tar.gz"] = ReleaseFile(
            filename="releasefile1.tar.gz", content=b"", md5_digest="12345"
        )
        root["pyramid"]["release1"]["releasefile1.tar.gz"].__parent__ = root["pyramid"]["release1"]

        self.request.matchdict["traverse"] = (root["pyramid"].__name__, root["pyramid"]["release1"].__name__)
        self.request.registry.settings["papaye.proxy"] = "true"
        view = ListReleaseFileView(root["pyramid"], self.request)

        response = view()

        self.assertIsInstance(response, dict)
        assert len(list(response["objects"])) == 82