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

Bugfix/updated schema for search-get_article #31

Merged
merged 2 commits into from
Jul 12, 2024
Merged

Conversation

yazdipour
Copy link
Owner

@yazdipour yazdipour commented Jul 12, 2024

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.

  • Bug Fixes:
    • Updated the GraphQL schema to use the new 'SearchItemFields' fragment, ensuring consistency and completeness of the search results.
  • Enhancements:
    • Added 'includeContent' parameter to the 'get_article' method to allow fetching article content optionally.
  • Documentation:
    • Fixed a minor formatting issue in the README.md file.
  • Tests:
    • Enhanced the 'test_get_articles' test to check for the presence of 'id' and 'content' fields in the search results.

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.
Copy link
Contributor

sourcery-ai bot commented Jul 12, 2024

Reviewer's Guide by Sourcery

This 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

Files Changes
omnivoreql/queries/Search.graphql
omnivoreql/omnivoreql.py
Updated the Search query to use a fragment for better reusability and added support for including content in the get_article method.
tests/test_omnivoreql.py
omnivoreql/omnivoreql.py
Enhanced the test_get_articles test to verify the inclusion of content and updated the get_article method to support the new include_content parameter.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@yazdipour yazdipour changed the title Bugfix/updated schema Bugfix/updated schema for search-get_article Jul 12, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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.

state
siteName
subscription
unsubMailTo

This comment was marked as off-topic.

@@ -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.

@@ -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)
Copy link
Contributor

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.

Suggested change
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"])
Copy link
Contributor

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"])
Copy link
Contributor

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.

Suggested change
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"])

@yazdipour yazdipour merged commit f135b32 into main Jul 12, 2024
3 checks passed
@yazdipour yazdipour deleted the bugfix/updated-schema branch July 12, 2024 14:31
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.

Content is not returned using get_articles
1 participant