Skip to content

Commit

Permalink
fix range flag bug, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinamullin committed Nov 14, 2024
1 parent 2420ddc commit e88ccf3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/ResultFlagsIndependent.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ TADA_FlagAboveThreshold <- function(.data, clean = FALSE, flaggedonly = FALSE) {
"TADA.ResultMeasure.MeasureUnitCode"
),
multiple = "all",
relationship = "many-to-one"
relationship = "many-to-many"
)

# Create flag column, flag rows where ResultMeasureValue > Maximum
Expand Down Expand Up @@ -666,7 +666,7 @@ TADA_FlagBelowThreshold <- function(.data, clean = FALSE, flaggedonly = FALSE) {
"TADA.ResultMeasure.MeasureUnitCode"
),
multiple = "all",
relationship = "many-to-one"
relationship = "many-to-many"
)

# Create flag column, flag rows where TADA.ResultMeasureValue < Minimum
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-ResultFlagsIndependent.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,19 @@ test_that("TADA_FindPotentialDuplicatsMultipleOrgs has non-NA values for each ro
expect_false(any(is.na(testdat$TADA.MonitoringLocationIdentifier)))
expect_false(any(is.na(testdat$TADA.ResultSelectedMultipleOrgs)))
})

test_that("range flag functions work", {
# use random data
upper <- TADA_RandomTestingData()

expect_no_error(TADA_FlagAboveThreshold(upper))
expect_no_warning(TADA_FlagAboveThreshold(upper))
expect_no_message(TADA_FlagAboveThreshold(upper))
expect_no_condition(TADA_FlagAboveThreshold(upper))

expect_no_error(TADA_FlagBelowThreshold(upper))
expect_no_warning(TADA_FlagBelowThreshold(upper))
expect_no_message(TADA_FlagBelowThreshold(upper))
expect_no_condition(TADA_FlagBelowThreshold(upper))

})

0 comments on commit e88ccf3

Please sign in to comment.