Skip to content

Trove classifiers API endpoint #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 7, 2016
Merged

Conversation

karan
Copy link

@karan karan commented Jun 7, 2016

#1241

WIP - @dstufft - I can't get the test to work. Any hints? :)

    def test_list_classifiers(pyramid_request):
        pyramid_request = pretend.stub(
            db=pretend.stub(
                query=pretend.stub(
                    order_by=pretend.stub(
                        all=lambda: 'abc'
                    )
                ),
            ),
        )
>       resp = pypi.list_classifiers(pyramid_request)

tests/unit/legacy/api/test_pypi.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @view_config(route_name="legacy.api.pypi.list_classifiers")
    def list_classifiers(request):
        classifiers = (
>           request.db.query(Classifier.classifier)
                      .order_by(Classifier.classifier)
                      .all()
        )
E       TypeError: 'stub' object is not callable

warehouse/legacy/api/pypi.py:83: TypeError

@dstufft
Copy link
Member

dstufft commented Jun 7, 2016

@karan it's trying to call pyramid_request.db.query(), but you have it as a stub object instead of a callable. In pretend you want that to be pretend.call_recorder(lambda *args: SOMEQUERYOBJECT).

Although I recommend not trying to stub out database access, and instead just using the db_request fixture to enable DB access and then insert some classifiers into the database and running the view to make sure it finds them.

@karan
Copy link
Author

karan commented Jun 7, 2016

@dstufft Ah perfect. I was a bit confused about db_request but now it makes sense!

Pushed the changes.

@dstufft dstufft merged commit ddec0f6 into pypi:master Jun 7, 2016
@dstufft
Copy link
Member

dstufft commented Jun 7, 2016

✨ 🍰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants