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

Scrape categories and topics for news.py #215

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

tianyizheng02
Copy link
Contributor

Fixes #204

Replace existing hard-coded news categories and topics with helper functions that scrape these values. The values are scraped when the user calls a function from the news module for the first time, and the scraped values are reused in all subsequent function calls.

Replace existing hard-coded news categories and topics with helper
functions that scrape these values. The values are scraped when the user
calls a function from the news module for the first time, and the
scraped values are reused in all subsequent function calls.
@tianyizheng02 tianyizheng02 marked this pull request as ready for review December 24, 2024 14:09
pittapi/news.py Outdated Show resolved Hide resolved
Rewrite news.py to cache categories and topics using the functools
@cache decorator rather than global variables
Pipfile.lock Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Are these version changes needed? You bump up the minimum Python version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of them aren't necessary, but the jinja2 version change is necessary as a security update (the repo current has 4 Dependabot alerts for security vulnerabilities in the current jinja2 version). I had simply run pipenv update when I was making my changes for this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Make the dependency changes in a different PR


topics = news.get_topics()

self.assertCountEqual(
Copy link
Member

Choose a reason for hiding this comment

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

Is this test going to hold true even into the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, all the tests for the news module are mocked. The mock files are in the tests/samples directory.

Revert dependency updates in Pipfile.lock and requirements.txt. The
updates will be left for a separate PR.
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.

Scrape categories and topics for news.py
3 participants