test: add unit test methodology for scrapers with fixtures#136
Closed
NewdlDewdl wants to merge 4 commits intoUTDNebula:developfrom
Closed
test: add unit test methodology for scrapers with fixtures#136NewdlDewdl wants to merge 4 commits intoUTDNebula:developfrom
NewdlDewdl wants to merge 4 commits intoUTDNebula:developfrom
Conversation
Addresses UTDNebula#46 by establishing a fixture-based testing approach for scrapers that avoids live network dependencies. Changes: - Extract testable helper functions from cometCalendar and coursebook scrapers - Add comprehensive unit tests covering HTTP request behavior, parsing logic, and caching - Create testdata/ directory with sample API responses and HTML fixtures - Document methodology in README: use fixtures + httptest.Server for deterministic tests Tests verify: - HTTP request construction (query params, headers) - Response parsing and error handling - Section ID extraction from HTML - File-based caching and missing ID filtering - Event time/location/filter parsing All tests pass and are fast (<1s) with no external dependencies.
Contributor
Author
|
@mikehquan19 made a small follow-up commit to match repo docs style:
Verification rerun:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses #46 by setting up a repeatable unit-test approach for scrapers.
What I changed:
scrapers/testdatascrapers/cometCalendar.goandscrapers/coursebook.goso request/parsing behavior can be tested directlyVerification run:
go test ./scrapersgo test ./parser ./uploaderBoth pass locally.
Note:
go test ./...still fails in existingutilscredentialed tests when local.envsecrets (likeLOGIN_NETID) are missing.