-
Notifications
You must be signed in to change notification settings - Fork 4
Update unit tests for new 2024 data and functions #78
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
Merged
jeancochrane
merged 4 commits into
2024-data-update
from
jeancochrane/72-update-unit-tests-to-include-2024-data-and-new-functions
Apr 2, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a4f8a4
Update unit tests for new 2024 data and functions
jeancochrane ef48dc8
Fix a few final lines of `test-tax_bill.R`
jeancochrane 28caaab
Add to vetdis calc in tests
jeancochrane dadbe77
Merge branch '2024-data-update' into jeancochrane/72-update-unit-test…
jeancochrane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,31 +18,32 @@ det_dt <- sample_tax_bills_detail | |
| pins <- c( | ||
| "14081020190000", "09274240240000", "07101010391078" | ||
| ) | ||
| years <- c(2019, 2019, 2018) | ||
| years <- 2024:2022 | ||
|
|
||
| test_that("bad/incorrect vector inputs throw errors", { | ||
| expect_error(tax_bill("2019", pins[1])) | ||
| expect_error(tax_bill("2024", pins[1])) | ||
| expect_error(tax_bill(numeric(0), pins[1])) | ||
| expect_error(tax_bill(2019, 14081020190000)) | ||
| expect_error(tax_bill(c(2000, 2019), pins[1])) | ||
| expect_error(tax_bill(2019, c("1408102019000", pins[2]))) | ||
| expect_error(tax_bill(2019, pins[1], tax_code_vec = 73105)) | ||
| expect_error(tax_bill(2019, pins[1], tax_code_vec = "5454")) | ||
| expect_error(tax_bill(2019, pins[2], simplify = "yes")) | ||
| expect_error(tax_bill(2018:2019, pins[2:3], simplify = c(TRUE, FALSE))) | ||
| expect_error(tax_bill(years[1], 14081020190000)) | ||
| expect_error(tax_bill(c(2000, years[1]), pins[1])) | ||
| expect_error(tax_bill(years[1], c("1408102019000", pins[2]))) | ||
| expect_error(tax_bill(years[1], pins[1], tax_code_vec = 73105)) | ||
| expect_error(tax_bill(years[1], pins[1], tax_code_vec = "5454")) | ||
| expect_error(tax_bill(years[1], pins[2], simplify = "yes")) | ||
| expect_error(tax_bill(years[2:1], pins[2:3], simplify = c(TRUE, FALSE))) | ||
| }) | ||
|
|
||
| test_that("bad/incorrect data frame inputs throw errors", { | ||
| expect_error(tax_bill(2019, pins[1], pin_dt = c(23000, 959051))) | ||
| expect_error(tax_bill(2019, pins[1], agency_dt = c("3232", "TIF"))) | ||
| expect_error(tax_bill(2019, pins[1], tif_dt = c(23000, 959051))) | ||
| expect_error(tax_bill(years[1], pins[1], pin_dt = c(23000, 959051))) | ||
| expect_error(tax_bill(years[1], pins[1], agency_dt = c("3232", "TIF"))) | ||
| expect_error(tax_bill(years[1], pins[1], tif_dt = c(23000, 959051))) | ||
| expect_error(tax_bill(years[1], pins[1], pin_tif_dt = c(23000, 959051))) | ||
| }) | ||
|
|
||
| test_that("non-unique values to main args throws error", { | ||
| expect_error(tax_bill(2019, pins[c(1, 1)])) | ||
| expect_error(tax_bill(c(2010, 2010), pins[1])) | ||
| expect_error(tax_bill(years[1], pins[c(1, 1)])) | ||
| expect_error(tax_bill(c(years[c(1, 1)]), pins[1])) | ||
| expect_error( | ||
| tax_bill(c(2010, 2010), pins[c(1, 2)], tax_code_vec = c("73105")) | ||
| tax_bill(years[c(1, 1)], pins[c(1, 2)], tax_code_vec = c("73105")) | ||
| ) | ||
| }) | ||
|
|
||
|
|
@@ -52,20 +53,21 @@ test_that("incorrect size inputs throw errors", { | |
| }) | ||
|
|
||
| test_that("data frame inputs throw errors when required cols missing", { | ||
| expect_error(tax_bill(2019, pins[1], pin_dt = data.table())) | ||
| expect_error(tax_bill(2019, pins[1], agency_dt = data.table())) | ||
| expect_error(tax_bill(2019, pins[1], tif_dt = data.table())) | ||
| expect_error(tax_bill(years[1], pins[1], pin_dt = data.table())) | ||
| expect_error(tax_bill(years[1], pins[1], agency_dt = data.table())) | ||
| expect_error(tax_bill(years[1], pins[1], tif_dt = data.table())) | ||
| expect_error(tax_bill(years[1], pins[1], pin_tif_dt = data.table())) | ||
| }) | ||
|
|
||
| test_that("function returns expected data type/structure", { | ||
| expect_s3_class(tax_bill(2018, pins[1]), "data.frame") | ||
| expect_s3_class(tax_bill(2018, pins[1]), "data.table") | ||
| expect_s3_class(tax_bill(years[1], pins[1]), "data.frame") | ||
| expect_s3_class(tax_bill(years[1], pins[1]), "data.table") | ||
| expect_equal( | ||
| key(tax_bill(2018, pins[1])), | ||
| key(tax_bill(years[1], pins[1])), | ||
| c("year", "pin", "agency_num") | ||
| ) | ||
| expect_named( | ||
| tax_bill(2018:2019, pins[1:2]), | ||
| tax_bill(years[1:2], pins[1:2]), | ||
| c( | ||
| "year", "pin", "class", "tax_code", "av", "eav", "agency_num", | ||
| "agency_name", "agency_major_type", "agency_minor_type", | ||
|
|
@@ -77,7 +79,7 @@ test_that("function returns expected data type/structure", { | |
| 0 | ||
| ) | ||
| expect_named( | ||
| tax_bill(2018:2019, pins[1:2], simplify = FALSE), | ||
| tax_bill(years[1:2], pins[1:2], simplify = FALSE), | ||
| c( | ||
| "year", "pin", "class", "tax_code", "av", "eav", "exe_total", | ||
| "agency_num", "agency_name", "agency_major_type", "agency_minor_type", | ||
|
|
@@ -92,8 +94,8 @@ test_that("function returns expected data type/structure", { | |
| sum(is.na(tax_bill(years[1], pins[1], simplify = FALSE))), | ||
| 0 | ||
| ) | ||
| expect_equal(dim(tax_bill(years[1], pins[1], simplify = TRUE)), c(12, 12)) | ||
| expect_equal(dim(tax_bill(years[1], pins[1], simplify = FALSE)), c(10, 25)) | ||
| 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)) | ||
|
Comment on lines
+97
to
+98
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| }) | ||
|
|
||
| test_that("returned amount/output correct for single PIN", { | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
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:There was a problem hiding this comment.
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:2024the output will include 2022 - 2023 and no rows for 2024?There was a problem hiding this comment.
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.