Skip to content

Fix pytests for openlibrary/records again #3708

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 2 commits into from
Aug 22, 2020
Merged

Fix pytests for openlibrary/records again #3708

merged 2 commits into from
Aug 22, 2020

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Aug 14, 2020

Closes #3586 and #3706 Enables pytest -vv openlibrary/records and uncovers:

  1. A way to leverage json.dumps() to compare dicts across both Python 2 and Python 3
  2. A simple, reliable way to convert thing strings to Things.

Technical

Testing

Yes. In Docker on both Python 2 and Python 3

Screenshot

Stakeholders

@cclauss cclauss requested review from cdrini and mekarpeles August 14, 2020 16:07
@cclauss cclauss changed the title Fix-pytests-for-openlibrary/records-again Fix pytests for openlibrary/records again Aug 14, 2020
"""Converts list of things into the output expected by users of the search API.

If input_query is non empty, narrow return keys to the ones in
this dictionary. Also, if the keys list is empty, use this to
construct a response with key = None.
"""
input_query = input_query or {} # Avoid a mutable default argument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

ret = web.ctx.site.save_many(things, 'Import new records.')
return [x.key for x in ret]
web.ctx.site.save_many(things, 'Import new records.')
return [thing['key'] for thing in things]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine, leaving a note/question re: whether we can guarantee 'key' is indeed a key, i.e. thing.get('key') v. thing['key'] but I imagine if thing is not None, it should have key

Copy link
Member

@mekarpeles mekarpeles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mekarpeles mekarpeles merged commit cc42075 into internetarchive:master Aug 22, 2020
@cclauss cclauss deleted the Fix-pytests-for-openlibrary/records-again branch August 22, 2020 20:18
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.

How do we modernize pytest_funcarg__xyz() tests?
2 participants