Skip to content

Astra parser unit test - #166

Draft
bvaic wants to merge 7 commits into
developfrom
astra-parser-unit-test
Draft

bvaic wants to merge 7 commits into
developfrom
astra-parser-unit-test

Conversation

@bvaic

@bvaic bvaic commented Apr 17, 2026

Copy link
Copy Markdown
Contributor
  • unit test currently only tests one day: 2027-03-31
  • sorted the buildings, rooms, and results in the parser to make the output deterministic which makes the unit test easier

Fixes: #150

bvaic added 6 commits April 14, 2026 23:28
* if no search index exists in mongo, one is created
* if the fields of the existing search index in mongo do not match the current model, the existing search index is updated
* the academic calendars are now uploaded with an additional url field containing the box url for the calendar
* bugfix: fixed past selector so that the links are extracted correctly and completely

Co-authored-by: SuchDominion shijiand2022@gmail.com
* test data for this unit test is held in `parser/testdata/astra/`
* currently only tests output of parsing one day: 2027-03-31
* made parser output deterministic by implementing sorting for buildings, rooms, and results
* the deterministic output makes the unit test much easier
@bvaic
bvaic requested a review from mikehquan19 April 17, 2026 06:34
@bvaic

bvaic commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

The failed checks are because it seems to be looking for a testdata/astra/input.html and I don't know why it's doing that. testdata/astra is a directory that I created to hold the test data for the astra parser unit test. Should I have done this differently?

@bvaic

bvaic commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor Author

I noticed that each test case directory like case_000 had an input.html file so I imagine that something thought that my astra directory was a test case directory. I just moved everything out of that directory and deleted the astra directory and now the checks pass. Maybe it would be better to have those files in a astra directory if there's a way to get around or fix that input.html check.

@justinschwerdtfeger
justinschwerdtfeger marked this pull request as draft September 24, 2026 18:30
@justinschwerdtfeger

justinschwerdtfeger commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

@bvaic can you fix merge conflicts? Thank you! Good work with this PR! 🎉

Comment thread parser/astraParser.go
Comment on lines +88 to +91

sort.Slice(result, func(i, j int) bool {
return result[i].Date < result[j].Date
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be outside the loop?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks identical to expected.json

astraTestDir := "testdata"

// Clean up parser output before starting the test
os.Remove(filepath.Join(astraTestDir, "astra.json"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of deleting the file, write the output to a temporary directory

@justinschwerdtfeger

justinschwerdtfeger commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

@bvaic Tests are failing bc the parser_test.go check all subdirectories in testdata. Not your fault, and I experienced a similar issue myself. I think I will fix this bug in a separate PR. One related issue is #186

This branch has not been deployed

No deployments
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.

Add unit-tests for the astra parser in parser/astraParser.go

2 participants