-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from getwilds/test
Test
- Loading branch information
Showing
12 changed files
with
243 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,22 +1,28 @@ | ||
# test_that("demo-crowding", { | ||
# test_crowding1 <- demo_crowding("WA", "hsa", "All Races (includes Hispanic)") | ||
# | ||
# | ||
# # object, length, dimensions, | ||
# # ranges -ex: greater than 10 rows | ||
# # errors | ||
# | ||
# | ||
# #expect_error() - catches an expected error | ||
# }) | ||
|
||
|
||
#' Test demo-crowding | ||
#' | ||
#' This testthat file test the demo-crowding function | ||
#' | ||
#tests class and typeof output | ||
test_that("Output data type is correct", { | ||
output <- demo_crowding("usa", "state", "All Races (includes Hispanic)") | ||
|
||
expect_equal(class(output), "data.frame", | ||
info = "Output should be a data frame") | ||
output <- demo_crowding("wa", "hsa", "All Races (includes Hispanic)") | ||
|
||
expect_equal(typeof(output), "list", | ||
info = "Output should have list storage type (since data frames are lists)") | ||
expect_true(inherits(output, "data.frame")) | ||
}) | ||
|
||
#Ensures that variables are present and working on SCP | ||
test_that("demo-crowding returns non-empty data frame", { | ||
crowding1 <- demo_crowding("wa", "hsa", "All Races (includes Hispanic)") | ||
expect_true(is.data.frame(crowding1)) | ||
}) | ||
|
||
#demo-crowding must have 5 columns | ||
test_that("demo-crowding has correct number of columns", { | ||
df <- demo_crowding("wa", "hsa", "All Races (includes Hispanic)") | ||
expected_columns <- 5 | ||
expect_equal(ncol(df), expected_columns) | ||
}) | ||
|
||
#parameter | ||
test_that("demo-crowding has correct parameters", { | ||
expect_error(demo_crowding()) | ||
}) |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#' Test risk-alcohol | ||
#' | ||
#' This testthat file test the risk-alcohol function | ||
#' | ||
#tests class and typeof output | ||
test_that("Output data type is correct", { | ||
output <- risk_alcohol(paste("binge drinking (4+ drinks on one occasion for women,", | ||
"5+ drinks for one occasion for men), ages 21+"), | ||
"all races (includes hispanic)", "both sexes") | ||
|
||
expect_true(inherits(output, "data.frame")) | ||
}) | ||
|
||
#Ensures that variables are present and working on SCP | ||
test_that("risk-alcohol returns non-empty data frame", { | ||
alcohol1 <- risk_alcohol(paste("binge drinking (4+ drinks on one occasion for women,", | ||
"5+ drinks for one occasion for men), ages 21+"), | ||
"all races (includes hispanic)", "both sexes") | ||
expect_true(is.data.frame(alcohol1)) | ||
}) | ||
|
||
#risk-alcohol must have 5 columns | ||
test_that("risk-alcohol has correct number of columns", { | ||
df <- risk_alcohol(paste("binge drinking (4+ drinks on one occasion for women,", | ||
"5+ drinks for one occasion for men), ages 21+"), | ||
"all races (includes hispanic)", "both sexes") | ||
expected_columns <- 6 | ||
expect_equal(ncol(df), expected_columns) | ||
}) | ||
|
||
#parameter | ||
test_that("risk-alcohol has correct parameters", { | ||
expect_error(demo_alcohol()) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#' Test risk-colorectal-screening | ||
#' | ||
#' This testthat file test the risk-colorectal-screening function | ||
#' | ||
#tests class and typeof output | ||
test_that("Output data type is correct", { | ||
output <- risk_colorectal_screening("ever had fobt, ages 50-75", area="wa") | ||
|
||
expect_true(inherits(output, "data.frame")) | ||
}) | ||
|
||
#Ensures that variables are present and working on SCP | ||
screening_options <- list( | ||
screening1 = risk_colorectal_screening("ever had fobt, ages 50-75", area = "wa"), | ||
screening2 = risk_colorectal_screening("guidance sufficient crc, ages 50-75", area = "wa"), | ||
screening3 = risk_colorectal_screening("had colonoscopy in past 10 years, ages 50-75", area = "wa"), | ||
screening4 = risk_colorectal_screening("home blood stool test in the past year, ages 45-75", | ||
"all races (includes hispanic)", "both sexes"), | ||
screening5 = risk_colorectal_screening("receieved at least one recommended crc test, ages 45-75", | ||
"all races (includes hispanic)", "both sexes") | ||
) | ||
|
||
for (option_name in names(screening_options)) { | ||
test_that("risk-colorectal-screening returns non-empty data frame", { | ||
option <- screening_options[[option_name]] | ||
expect_true(is.data.frame(option)) | ||
}) | ||
} | ||
|
||
#risk-colorectal-screening must have 5 columns | ||
test_that("risk-colorectal-screening has correct number of columns", { | ||
df1 <- risk_colorectal_screening("ever had fobt, ages 50-75", area="wa") | ||
df2 <- risk_colorectal_screening("home blood stool test in the past year, ages 45-75", | ||
"all races (includes hispanic)","both sexes") | ||
expected_columns1 <- 5 | ||
expected_columns2 <- 6 | ||
expect_equal(ncol(df1), expected_columns1) | ||
expect_equal(ncol(df2), expected_columns2) | ||
}) | ||
|
||
#test error handling | ||
test_that("risk-colorectal-screening handles invalid colorectal_screening parameters", { | ||
expect_error( | ||
risk_colorectal_screening("ever had fobt, ages 50-75", race="all races (includes hispanic)"), | ||
"for this screening type, area must NOT be NULL and Race and Sex must be NULL" | ||
) | ||
expect_error( | ||
risk_colorectal_screening("home blood stool test in the past year, ages 45-75", | ||
"all races (includes hispanic)"), | ||
"For this screening type, Race and Sex must not be NULL" | ||
) | ||
}) | ||
|
||
#parameter | ||
test_that("risk-colorectal-screening has correct parameters", { | ||
expect_error(risk_colorectal_screening()) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#' Test risk-diet-exercise | ||
#' | ||
#' This testthat file test the risk-diet-exercise function | ||
#' | ||
#tests class and typeof output | ||
test_that("Output data type is correct", { | ||
output <- risk_diet_exercise("bmi is healthy, ages 20+", | ||
"all races (includes hispanic)", "both sexes") | ||
|
||
expect_true(inherits(output, "data.frame")) | ||
}) | ||
|
||
#Ensures that variables are present and working on SCP | ||
diet_exercise_options <- c("bmi is healthy, ages 20+", "bmi is obese, ages 20+", | ||
"bmi is obese, high school survey", "bmi is overweight, high school survey", | ||
"consumed 1 or more fruits per day", "consumed 1 or more vegetables per day", | ||
"no leisure time physical activity") | ||
|
||
for (option in diet_exercise_options) { | ||
test_that("risk_diet_exercise returns non-empty data frame", { | ||
result <- risk_diet_exercise(option, "all races (includes hispanic)", "both sexes") | ||
expect_true(is.data.frame(result)) | ||
}) | ||
} | ||
|
||
#risk-diet-exercise must have 5 columns | ||
test_that("risk-diet-exercise has correct number of columns", { | ||
df1 <- risk_diet_exercise("bmi is healthy, ages 20+", | ||
"all races (includes hispanic)", "both sexes") | ||
df2 <- risk_diet_exercise("bmi is obese, high school survey", | ||
"all races (includes hispanic)", "males") | ||
expected_columns1 <- 6 | ||
expected_columns2 <- 5 | ||
expect_equal(ncol(df1), expected_columns1) | ||
expect_equal(ncol(df2), expected_columns2) | ||
|
||
}) | ||
|
||
#parameter | ||
test_that("risk-diet-exercise has correct parameters", { | ||
expect_error(risk_diet_exercise()) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("multiplication works", { | ||
expect_equal(2 * 2, 4) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("multiplication works", { | ||
expect_equal(2 * 2, 4) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#' Test risk-womens health | ||
#' | ||
#' This testthat file test the risk-womens health function | ||
#' | ||
#tests class and typeof output | ||
# test_that("Output data type is correct", { | ||
# output <- risk_womens_health("bmi is healthy, ages 20+", | ||
# "all races (includes hispanic)", "both sexes") | ||
# | ||
# expect_true(inherits(output, "data.frame")) | ||
# }) | ||
# | ||
# #Ensures that variables are present and working on SCP | ||
# womens_health_options <- c("bmi is healthy, ages 20+", "bmi is obese, ages 20+", | ||
# "bmi is obese, high school survey", "bmi is overweight, high school survey", | ||
# "consumed 1 or more fruits per day", "consumed 1 or more vegetables per day", | ||
# "no leisure time physical activity") | ||
# | ||
# for (option in womens_health_options) { | ||
# test_that("risk_womens_health returns non-empty data frame", { | ||
# result <- risk_womens_health(option, "all races (includes hispanic)", "both sexes") | ||
# expect_true(is.data.frame(result)) | ||
# }) | ||
# } | ||
# | ||
# #risk-womens health must have 5 columns | ||
# test_that("risk-womens health has correct number of columns", { | ||
# df1 <- risk_womens_health("bmi is healthy, ages 20+", | ||
# "all races (includes hispanic)", "both sexes") | ||
# df2 <- risk_womens_health("bmi is obese, high school survey", | ||
# "all races (includes hispanic)", "males") | ||
# expected_columns1 <- 6 | ||
# expected_columns2 <- 5 | ||
# expect_equal(ncol(df1), expected_columns1) | ||
# expect_equal(ncol(df2), expected_columns2) | ||
# | ||
# }) | ||
# | ||
# #parameter | ||
# test_that("risk-womens health has correct parameters", { | ||
# expect_error(risk_womens_health()) | ||
# }) |