Exemplo n.º 1
0
    def test_files_no_name(self, db_request):
        version = "10.0.0"

        db_request.params = {"version": version}

        with pytest.raises(HTTPNotFound):
            pypi.files(db_request)
Exemplo n.º 2
0
    def test_files_no_version(self, db_request):
        name = "pip"

        db_request.params = {"name": name}

        with pytest.raises(HTTPNotFound):
            pypi.files(db_request)
Exemplo n.º 3
0
    def test_files_no_name(self, db_request):
        version = "10.0.0"

        db_request.params = {"version": version}

        with pytest.raises(HTTPNotFound):
            pypi.files(db_request)
Exemplo n.º 4
0
    def test_files_no_version(self, db_request):
        name = "pip"

        db_request.params = {"name": name}

        with pytest.raises(HTTPNotFound):
            pypi.files(db_request)
Exemplo n.º 5
0
    def test_files(self, db_request):
        name = "pip"
        version = "10.0.0"

        db_request.params = {"name": name, "version": version}
        db_request.route_path = pretend.call_recorder(
            lambda *a, **kw: f"/project/{name}/{version}/#files"
        )

        result = pypi.files(db_request)

        assert isinstance(result, HTTPMovedPermanently)
        assert result.headers["Location"] == (f"/project/{name}/{version}/#files")
        assert result.status_code == 301
        assert db_request.route_path.calls == [
            pretend.call(
                "packaging.release", name=name, version=version, _anchor="files"
            )
        ]
Exemplo n.º 6
0
    def test_files(self, db_request):
        name = "pip"
        version = "10.0.0"

        db_request.params = {"name": name, "version": version}
        db_request.route_path = pretend.call_recorder(
            lambda *a, **kw: f'/project/{name}/{version}/#files')

        result = pypi.files(db_request)

        assert isinstance(result, HTTPMovedPermanently)
        assert result.headers['Location'] == (
            f'/project/{name}/{version}/#files')
        assert result.status_code == 301
        assert db_request.route_path.calls == [
            pretend.call('packaging.release',
                         name=name,
                         version=version,
                         _anchor="files")
        ]