-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Bugfix/updated schema for search-get_article #31
Conversation
The `get_article` method in the `OmnivoreQL` class now accepts an optional `include_content` parameter. This parameter allows the user to specify whether or not to include the content of the article in the response. This change provides more flexibility and control when retrieving articles.
Reviewer's Guide by SourceryThis pull request addresses issue #29 by updating the GraphQL schema to use a fragment for the Search query, improving reusability and maintainability. It also adds support for including content in the get_article method and updates the corresponding tests to verify this functionality. Additionally, a minor fix was made to the README.md file to correct a duplicated header. File-Level Changes
Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @yazdipour - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟡 Security: 1 issue found
- 🟡 Testing: 3 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
highlights { | ||
...HighlightFields | ||
} | ||
...SearchItemFields |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
state | ||
siteName | ||
subscription | ||
unsubMailTo |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -143,6 +143,7 @@ def get_article(self, username: str, slug: str, format: str = None): | |||
"username": username, | |||
"slug": slug, | |||
"format": format, | |||
"includeContent": include_content, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -82,11 +82,13 @@ def test_save_page(self): | |||
|
|||
def test_get_articles(self): | |||
# When | |||
articles = self.client.get_articles() | |||
articles = self.client.get_articles(include_content=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Missing test for include_content=False
case
It would be beneficial to add a test case where include_content
is set to False
to ensure that the function behaves correctly in both scenarios.
articles = self.client.get_articles(include_content=True) | |
articles_with_content = self.client.get_articles(include_content=True) | |
articles_without_content = self.client.get_articles(include_content=False) | |
self.assertIsNotNone(articles_with_content) | |
self.assertIsNotNone(articles_without_content) |
# Then | ||
self.assertIsNotNone(articles) | ||
self.assertNotIn("errorCodes", articles["search"]) | ||
self.assertGreater(len(articles["search"]["edges"]), 0) | ||
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (testing): Check for empty edges list
Before accessing articles["search"]["edges"][0]
, it would be prudent to check if articles["search"]["edges"]
is not empty to avoid potential index errors.
# Then | ||
self.assertIsNotNone(articles) | ||
self.assertNotIn("errorCodes", articles["search"]) | ||
self.assertGreater(len(articles["search"]["edges"]), 0) | ||
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["id"]) | ||
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["content"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Add assertion for include_content
parameter
Consider adding an assertion to verify that the include_content
parameter is correctly passed and affects the response as expected.
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["content"]) | |
self.assertIn("include_content", articles["search"]["parameters"]) | |
self.assertTrue(articles["search"]["parameters"]["include_content"]) | |
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["content"]) |
Closes #29
Summary by Sourcery
This pull request updates the GraphQL schema to use a new fragment for search results, adds an optional parameter to fetch article content, fixes a minor README formatting issue, and enhances the test coverage for article fetching.