Skip to content
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

Rough in search method #67

Merged
merged 9 commits into from
Apr 18, 2018
Merged

Rough in search method #67

merged 9 commits into from
Apr 18, 2018

Conversation

hancush
Copy link
Collaborator

@hancush hancush commented Apr 16, 2018

Related to Metro-Records/la-metro-councilmatic#263, adds a method to search the Events API.

TO DO

@fgregg
Copy link
Contributor

fgregg commented Apr 17, 2018

@hancush this is ready for your review

legistar/base.py Outdated
Arguments:

route -- The path to search, i.e. /matters/, /events/, etc
item_key -- The unique id for the items that you are searching.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure I understand what this means.

from legistar import base


class TestAPISearch(unittest.TestCase):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why use unittest here, instead of pytest?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what pytest says to do? https://docs.pytest.org/en/latest/unittest.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems like that's what pytest says to do "for leveraging existing unittest-based test suites." Since legistar doesn't have an existing test suite (unless I missed it?), I think it'd be great to just use pytest conventions, with a fixture for setup in conftest, that's included in each test. You can still use classes to organize tests, if you like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fgregg Is this something you want to do, in this PR?

Copy link
Collaborator Author

@hancush hancush left a comment

Choose a reason for hiding this comment

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

I hit the wrong button for comments, so I just submitted them inline. It won't let me approve or request changes anyhow! :-)

@fgregg
Copy link
Contributor

fgregg commented Apr 17, 2018

@hancush okay, updated the docstring. let me know if that helps.

legistar/base.py Outdated
and item key in a wrapper function.

If you were searching for matters, then this would looke like
search('/matters/', 'MatterId', your_search_condition)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the sentence about wrapper functions is a little confusing. May I suggest striking it, in lieu of a format like:

"""
Base function for searching the Legistar API.

Arguments:
blah

Examples:
# Search for bills introduced after Jan. 1, 2017
search('/matters/', 'MatterId', "MatterIntroDate gt datetime'2017-01-01'")
"""

@fgregg
Copy link
Contributor

fgregg commented Apr 17, 2018

okay @hancush updated the docstring again.

@hancush
Copy link
Collaborator Author

hancush commented Apr 18, 2018

Re: review, please see the open thread above on pytest, @fgregg.

@fgregg
Copy link
Contributor

fgregg commented Apr 18, 2018

@hancush okay, using pytest conventions.


from legistar import base

@pytest.fixture(scope="module")
Copy link
Collaborator Author

@hancush hancush Apr 18, 2018

Choose a reason for hiding this comment

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

I'd break this fixture out into test/conftest.py, that way it will be available if we want to add more test modules later. (FWIW, if you do that, you don't need to import fixtures from conftest, here.)

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like something we can do once we have more tests? Or is it a strong DataMade convention that fixtures should only go in conftest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would argue that it's a convention. A centralized location for generic fixtures, like this one, lowers the barrier to writing additional test modules moving forward (because that fixture will be available for use in those modules). If there fixtures are truly specific to a test module, ok – but this one seems reusable beyond testing one method on the base scraper.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes this thing a bit less readable, but conventions are important. I've made the change.

Is there anything else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This seems fine to me!

@fgregg fgregg merged commit cc0a071 into master Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants