Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
01eb0bf
Merge pull request #18 from PHSKC-APDE/dev
rwbuie Mar 31, 2025
daebc38
expand testing analytic set instructions
rwbuie Apr 1, 2025
18d86b6
remove unneeded tests
rwbuie Apr 1, 2025
d1a383a
sepearte into 2 set version of hgelper
rwbuie Apr 1, 2025
38105f5
rename indicator to "indicator1"
rwbuie Apr 1, 2025
ff0df91
variable modeller able to produce code for modelling a provided facto…
rwbuie Apr 2, 2025
02f0e3d
fixed "NA" and added remaining data type catchers for data modeller f…
rwbuie Apr 3, 2025
c519742
added optioin to not report failed data models
rwbuie Apr 3, 2025
f1017ce
have working pipeline to create generic dataframes from actual DT
rwbuie Apr 4, 2025
d050bc4
completed prototype of data generator
rwbuie Apr 7, 2025
84c3371
bug fix and format handling for data generated. rename to data modeller
rwbuie Apr 8, 2025
9cde19d
updated comments for current state
rwbuie Apr 8, 2025
40695eb
cleaning some testing code
rwbuie Apr 9, 2025
eaaadae
fixed parsing error and improved and standardized reporting for data …
rwbuie Apr 10, 2025
008c715
fixed typing error, implemented test solution for continuous numerics…
rwbuie Apr 10, 2025
4b1feb4
clean test code
rwbuie Apr 10, 2025
781a21e
stable with generic analysis set and data, and modelled death and brf…
rwbuie Apr 11, 2025
8a67eed
added test for CHI generate estimates
rwbuie Apr 11, 2025
575c50b
fixed chi_geo_kc levels for generic data generated by setup_test_data()
rwbuie Apr 11, 2025
fadba24
encapsulate connection test
rwbuie Apr 12, 2025
ff20a99
suppressed warnings where unimportant
rwbuie Apr 12, 2025
7121e94
unresolved: error when trtying to test chi_generate_metadata. Somethi…
rwbuie Apr 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
502 changes: 498 additions & 4 deletions tests/testthat/helper.R

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions tests/testthat/test-chi_generate_analysis_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ test_that("chi_generate_analysis_set validates inputs", {
expect_error(chi_generate_analysis_set(data_source = 123), "data_source must be a single character string")
expect_error(chi_generate_analysis_set(CHIestimates = 123), "CHIestimates must be a data.table or data.frame")
})

test_that("chi_generate_analysis_set generates expected analysis set from CHI estimates", {
TestData <- setup_test_data()
DT_test_analysis_instructions_results <- apde.chi.tools::chi_generate_tro_shell(TestData$my.analysis_set_twosets, end.year = 2023, year.span = 3, trend.span = 3, trend.periods = 5)
DT_test_chi_calc_output <- suppressWarnings(apde.chi.tools::chi_calc(ph.data = TestData$my.generic_data, ph.instructions = DT_test_analysis_instructions_results, source_name = "generic_test", source_date = as.Date("2025-04-10"), ci = .80))
DT_recreated_analysis_set <- suppressWarnings(chi_generate_analysis_set(CHIestimates = DT_test_chi_calc_output))
expect_equal(all.equal(TestData$my.analysis_set_twosets[order(cat1,set)] , DT_recreated_analysis_set[order(cat1,set)]),TRUE)
})
5 changes: 0 additions & 5 deletions tests/testthat/test-chi_process_trends.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-chi_qa.R

This file was deleted.

26 changes: 15 additions & 11 deletions tests/testthat/test-chi_sql_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
test_that("chi_update_sql validates inputs", {
test_data <- setup_test_data()

expect_warning(
chi_update_sql(
CHIestimates = test_data$my.estimate,
CHImetadata = test_data$my.metadata,
table_name = 'JustTesting',
server = 'development',
replace_table = FALSE
),
"Validation may be flawed for the following variables because they are 100% missing"
)

con_status <- test_data$my.hhsaw_status_test()
if(con_status == 1) {
expect_warning(
chi_update_sql(
CHIestimates = test_data$my.estimate,
CHImetadata = test_data$my.metadata,
table_name = 'JustTesting',
server = 'development',
replace_table = FALSE
),
"Validation may be flawed for the following variables because they are 100% missing"
)
} else {
message("connection test skipped")
}
expect_error(chi_update_sql(),
"The results table to push to SQL \\(CHIestimates\\) is missing")
expect_error(suppressWarnings(chi_update_sql(CHIestimates = test_data$my.estimate)),
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test_chi_generate_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ test_that("chi_generate_metadata handles valid inputs", {

expect_error(chi_generate_metadata(), "meta.old must be provided")
expect_error(chi_generate_metadata(meta.old = test_data$my.metadata), "est.current must be provided")

# why does this test fail? the DTs are not properly constructed, perhaps I need to update packages? will try later
#DTtest <- test_data$my.estimate
#DTtest[tab,] # throws error
#chi_generate_metadata(meta.old = test_data$my.metadata, est.current = test_data$my.estimate)

})