Skip to content

test: add unit test methodology for scrapers with fixtures#136

Closed
NewdlDewdl wants to merge 4 commits intoUTDNebula:developfrom
NewdlDewdl:feat/issue-46-scraper-test-methodology
Closed

test: add unit test methodology for scrapers with fixtures#136
NewdlDewdl wants to merge 4 commits intoUTDNebula:developfrom
NewdlDewdl:feat/issue-46-scraper-test-methodology

Conversation

@NewdlDewdl
Copy link
Contributor

@NewdlDewdl NewdlDewdl commented Mar 4, 2026

This PR addresses #46 by setting up a repeatable unit-test approach for scrapers.

What I changed:

  • Added fixture-based scraper tests under scrapers/testdata
  • Refactored small helper paths in scrapers/cometCalendar.go and scrapers/coursebook.go so request/parsing behavior can be tested directly
  • Added coverage for:
    • representative success payloads
    • empty/sparse payloads
    • malformed/non-200 responses
    • section ID extraction and missing-file filtering

Verification run:

  • go test ./scrapers
  • go test ./parser ./uploader

Both pass locally.

Note: go test ./... still fails in existing utils credentialed tests when local .env secrets (like LOGIN_NETID) are missing.

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

@mikehquan19 made a small follow-up commit to match repo docs style:

Verification rerun:

  • go test ./parser ./uploader

@mikehquan19 mikehquan19 closed this Mar 4, 2026
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