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

Improve Unit Test Coverage and Cache Functionality for QuoteScraper #475

Closed
wants to merge 3 commits into from

Conversation

smog-root
Copy link
Contributor

Note: Add SWOC and a BEGINNER label to this PR! and Don't forget to Update points to SWOC leaderboard

Summary:

This PR introduces improvements to the testing suite for the QuoteScraper class. It refines the existing unit tests, ensuring better handling of dynamic fields, better test coverage, and improved reliability of the tests.

Detailed Changes:

test_parse_quote_element_valid:

  • Refined the test to ignore the scraped_at field when comparing the expected and actual Quote objects, ensuring a stable comparison for the remaining fields.

test_parse_quote_element_missing_author:

  • This test verifies that when a quote is missing an author, it properly returns None.

test_cache_functionality:

  • This test mocks the cache loading (load_cache) and saving (save_cache) methods to verify that cached quotes are correctly reused and updated during scraping.

test_parse_quote_element_with_datetime_mock:

  • Mocked datetime.now() to return a fixed timestamp, ensuring that tests involving scraped_at are consistent and deterministic.

test_fetch_page_failure:

  • Enhanced the failure test to check that the scraper handles errors correctly when a page fetch fails (e.g., 404 or timeout).

Copy link
Contributor

github-actions bot commented Jan 5, 2025

👋 Thank you for opening this pull request! We're excited to review your contribution. Please give us a moment, and we'll get back to you shortly!

Feel free to join our community on Discord to discuss more!

@github-actions github-actions bot requested a review from UTSAVS26 January 5, 2025 03:35
@UTSAVS26
Copy link
Owner

UTSAVS26 commented Jan 5, 2025

@smog-root where is the issue for this PR?

@smog-root
Copy link
Contributor Author

@smog-root where is the issue for this PR?

Creating a issue and then getting assigned.. takes time.. so I directly submitted PR!

@UTSAVS26
Copy link
Owner

UTSAVS26 commented Jan 5, 2025

@smog-root where is the issue for this PR?

Creating a issue and then getting assigned.. takes time.. so I directly submitted PR!

Please follow this process:

  1. First, raise an issue in the repository.
  2. Wait for the maintainers or me to verify whether the issue is valid.
  3. Once the issue is verified, it will be assigned to you.
  4. After the assignment, you can then proceed to open a pull request (PR).

Thank you for your cooperation!

@UTSAVS26 UTSAVS26 closed this Jan 5, 2025
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.

2 participants