Skip to content

Update unit tests for new 2024 data and functions#78

Merged
jeancochrane merged 4 commits into
2024-data-updatefrom
jeancochrane/72-update-unit-tests-to-include-2024-data-and-new-functions
Apr 2, 2026
Merged

Update unit tests for new 2024 data and functions#78
jeancochrane merged 4 commits into
2024-data-updatefrom
jeancochrane/72-update-unit-tests-to-include-2024-data-and-new-functions

Conversation

@jeancochrane
Copy link
Copy Markdown
Member

@jeancochrane jeancochrane commented Mar 26, 2026

This PR updates our unit tests so that they test the 2024 changes to data (#63, #65) and functions (#69).

Note that there is one important set of tests that this PR does not touch: The tests that run on sample tax bills stored in the data-raw/sample_tax_bills/ subdirectory. A subsequent PR (#79) will update those tests, since they require the addition of a substantial number of new files, and I want to keep this diff as small as possible. I have also not yet explicitly tested the change to TIF calculation logic in tax_bill(), and am planning to do that in #79, since I think it will be easiest to do using sample tax bills.

Comment thread R/lookup.R
Comment on lines +367 to +369
# Make sure to remove any years after 2023 from the year vector, since
# otherwise we risk silently returning null TIF shares for post-2024 TIFs
year <- year[year <= 2023]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change aligns the behavior of lookup_tif() with its docstring, which states:

Returns 0 rows for any input year after 2023. For tax years 2024 and later, use lookup_pin_tif to lookup a PIN's TIF share.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to confirm - so this will ensure that even if a user inputs multiple years, such as 2022:2024 the output will include 2022 - 2023 and no rows for 2024?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's right! I'm not sure if that's the most intuitive behavior for end users, but it at least conforms with the specification that we describe in the function documentation.

Comment on lines +97 to +98
expect_equal(dim(tax_bill(years[1], pins[1], simplify = TRUE)), c(11, 12))
expect_equal(dim(tax_bill(years[1], pins[1], simplify = FALSE)), c(9, 25))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The number of agencies for these PINs has changed in the past few years, so we update the test to reflect the new count of agency line items.

@jeancochrane jeancochrane marked this pull request as ready for review March 27, 2026 16:12
Copy link
Copy Markdown
Member

@kyrasturgill kyrasturgill left a comment

Choose a reason for hiding this comment

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

I am not as familiar with unit testing but these additions all make sense to me and functioned when I ran them! I don't really have any edits, just a couple tiny clarifications.

Comment thread R/lookup.R
Comment on lines +367 to +369
# Make sure to remove any years after 2023 from the year vector, since
# otherwise we risk silently returning null TIF shares for post-2024 TIFs
year <- year[year <= 2023]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to confirm - so this will ensure that even if a user inputs multiple years, such as 2022:2024 the output will include 2022 - 2023 and no rows for 2024?

Comment thread tests/testthat/test-lookup.R Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this actually impacts the output of this test, but should we add the exe_vet_dis_100 here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, done in 28caaab!

@jeancochrane
Copy link
Copy Markdown
Member Author

@kyrasturgill Do you want to take a final look at this before I merge, or is it good to go?

@jeancochrane jeancochrane merged commit ea4c5fa into 2024-data-update Apr 2, 2026
7 checks passed
@jeancochrane jeancochrane deleted the jeancochrane/72-update-unit-tests-to-include-2024-data-and-new-functions branch April 2, 2026 16:29
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