Skip to content
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

fix expect_s3_class() tests #182

Merged
merged 11 commits into from
Dec 18, 2024
4 changes: 2 additions & 2 deletions tests/testthat/test-check_file_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ test_that("check_file_exists works", {

expect_s3_class(
check_file_exists(file_path, hub_path),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)

file_path <- "team1-goodmodel/2022-10-15-team1-goodmodel.csv"
expect_s3_class(
check_file_exists(file_path, hub_path),
c("check_error", "rlang_message", "message", "condition")
c("check_error")
)

expect_error(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_file_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ test_that("check_file_n works", {
file_path = "team1-goodmodel/2022-10-08-team1-goodmodel.csv",
hub_path
),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)

expect_s3_class(
check_file_n(
file_path = "team1-goodmodel/2022-10-08-team1-goodmodel.parquet",
hub_path
),
c("check_failure", "hub_check", "rlang_error", "error", "condition")
c("check_failure")
)

expect_snapshot(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-check_file_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ test_that("check_file_read works", {
hub_path = hub_path
)
),
c("check_error", "hub_check", "rlang_error", "error", "condition")
c("check_error")
)
})
6 changes: 3 additions & 3 deletions tests/testthat/test-check_metadata_file_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ test_that("check_metadata_file_exists works", {

expect_s3_class(
check_metadata_file_exists(hub_path, "hub-baseline.yml"),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_file_exists(hub_path, "hub-baseline.yml")
)

expect_s3_class(
check_metadata_file_exists(hub_path = "random_path", "hub-baseline.yml"),
c("check_error", "rlang_error", "error", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_file_exists(hub_path = "random_path", "hub-baseline.yml")
)

expect_s3_class(
check_metadata_file_exists(hub_path = hub_path, "random_path"),
c("check_error", "rlang_error", "error", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_file_exists(hub_path = hub_path, "random_path")
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-check_metadata_file_ext.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
test_that("check_metadata_file_ext works", {
expect_s3_class(
check_metadata_file_ext("hub-baseline.yml"),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_file_ext("hub-baseline.yml")
)

expect_s3_class(
check_metadata_file_ext("hub-baseline.yaml"),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_file_ext("hub-baseline.yaml")
)

expect_s3_class(
check_metadata_file_ext("hub-baseline.txt"),
c("check_error", "rlang_error", "error", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_file_ext("hub-baseline.txt")
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-check_metadata_file_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("check_metadata_file_name works", {
file_path = "hub-baseline.yml",
hub_path = hub_path
),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_file_name(
Expand All @@ -20,7 +20,7 @@ test_that("check_metadata_file_name works", {
file_path = "hub-baseline-with-model_id.yml",
hub_path = hub_path
),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_file_name(
Expand All @@ -34,7 +34,7 @@ test_that("check_metadata_file_name works", {
file_path = "hub-baseline-with-wrong-model_id.yml",
hub_path = hub_path
),
c("check_error", "rlang_message", "message", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_file_name(
Expand All @@ -48,7 +48,7 @@ test_that("check_metadata_file_name works", {
file_path = "hub-baseline-no-abbrs-or-model_id.yml",
hub_path = hub_path
),
c("check_error", "rlang_message", "message", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_file_name(
Expand All @@ -62,7 +62,7 @@ test_that("check_metadata_file_name works", {
file_path = "team1-goodmodel.yaml",
hub_path = hub_path
),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_file_name(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_metadata_matches_schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("check_metadata_matches_schema works", {
file_path = "hub-baseline.yml",
hub_path = hub_path
),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_matches_schema(
Expand All @@ -20,7 +20,7 @@ test_that("check_metadata_matches_schema works", {
file_path = "team1-goodmodel.yaml",
hub_path = hub_path
),
c("check_error", "rlang_message", "message", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_matches_schema(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_metadata_schema_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ test_that("check_metadata_schema_exists works", {

expect_s3_class(
check_metadata_schema_exists(hub_path),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_metadata_schema_exists(hub_path)
)

expect_s3_class(
check_metadata_schema_exists(hub_path = "random_path"),
c("check_error", "rlang_error", "error", "condition")
c("check_error")
)
expect_snapshot(
check_metadata_schema_exists(hub_path = "random_path")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_submission_metadata_file_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("check_metadata_file_exists works", {
hub_path = hub_path,
file_path = "hub-baseline/2022-10-01-hub-baseline.csv"
),
c("check_success", "rlang_message", "message", "condition")
c("check_success")
)
expect_snapshot(
check_submission_metadata_file_exists(
Expand All @@ -20,7 +20,7 @@ test_that("check_metadata_file_exists works", {
hub_path = hub_path,
file_path = "random-model/2022-10-01-random-model.csv"
),
c("check_error", "rlang_error", "error", "condition")
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

c("check_failure")
)
expect_snapshot(
check_submission_metadata_file_exists(
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-check_tbl_spl_compound_tid.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ test_that("check_tbl_spl_compound_tid works", {
# Ensure other checks pass
expect_s3_class(
check_tbl_spl_non_compound_tid(tbl_error, round_id, file_path, hub_path),
c("check_success", "hub_check", "rlang_message", "message", "condition")
c("check_success")
)
expect_s3_class(
check_tbl_spl_compound_tid(tbl_error, round_id, file_path, hub_path),
c("check_success", "hub_check", "rlang_message", "message", "condition")
check_tbl_spl_n(tbl_error, round_id, file_path, hub_path),
c("check_success")
)
})

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_tbl_spl_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ test_that("check_tbl_spl_n works", {
tbl_const_error, round_id,
file_path, hub_path
),
c("check_success", "hub_check", "rlang_message", "message", "condition")
c("check_success")
)
expect_s3_class(
check_tbl_spl_compound_tid(
tbl_const_error, round_id,
file_path, hub_path
),
c("check_success", "hub_check", "rlang_message", "message", "condition")
c("check_success")
)


Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_tbl_spl_non_compound_tid.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ test_that("check_tbl_spl_non_compound_tid works", {
# Ensure other checks pass
expect_s3_class(
check_tbl_spl_compound_tid(tbl_error, round_id, file_path, hub_path),
c("check_success", "hub_check", "rlang_message", "message", "condition")
c("check_success")
)
expect_s3_class(
check_tbl_spl_n(tbl_error, round_id, file_path, hub_path),
c("check_success", "hub_check", "rlang_message", "message", "condition")
c("check_success")
)
})

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_tbl_values_required.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ test_that(

expect_s3_class(
check,
c("check_failure", "hub_check", "rlang_warning", "warning", "condition")
c("check_failure")
)

# Expect that values for output type IDs "0.1000000000000000055511",
Expand Down Expand Up @@ -177,7 +177,7 @@ test_that(
file_path = file_path,
hub_path = hub_path
),
c("check_success", "hub_check", "rlang_message", "message", "condition")
c("check_success")
)
}
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-new_hub_validations.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test_that("new_hub_validations works", {
expect_snapshot(str(new_hub_validations()))
expect_s3_class(
new_hub_validations(),
c("hub_validations", "list")
c("hub_validations")
)


Expand All @@ -23,6 +23,6 @@ test_that("new_hub_validations works", {
file_exists = check_file_exists(file_path, hub_path),
file_name = check_file_name(file_path)
),
c("hub_validations", "list")
c("hub_validations")
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-validate_model_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("validate_model_data works", {
)
expect_s3_class(
validate_model_data(hub_path, file_path),
c("hub_validations", "list")
c("hub_validations")
)

expect_snapshot(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-validate_model_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_that("validate_model_file works", {
validate_model_file(hub_path,
file_path = "team1-goodmodel/2022-10-08-team1-goodmodel.csv"
),
c("hub_validations", "list")
c("hub_validations")
)

# File with validation error
Expand All @@ -28,7 +28,7 @@ test_that("validate_model_file works", {
validate_model_file(hub_path,
file_path = "team1-goodmodel/2022-10-15-team1-goodmodel.csv"
),
c("hub_validations", "list")
c("hub_validations")
)
})

Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-validate_model_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_that("validate_model_metadata works", {
)
expect_s3_class(
validate_model_metadata(hub_path, file_path),
c("hub_validations", "list")
c("hub_validations")
)

file_path <- "hub-baseline.yml"
Expand All @@ -20,7 +20,7 @@ test_that("validate_model_metadata works", {
)
expect_s3_class(
validate_model_metadata(hub_path, file_path),
c("hub_validations", "list")
c("hub_validations")
)

file_path <- "hub-baseline-no-abbrs-or-model_id.yml"
Expand All @@ -31,7 +31,7 @@ test_that("validate_model_metadata works", {
)
expect_s3_class(
validate_model_metadata(hub_path, file_path),
c("hub_validations", "list")
c("hub_validations")
)

file_path <- "2020-10-06-random-path.csv"
Expand All @@ -42,6 +42,6 @@ test_that("validate_model_metadata works", {
)
expect_s3_class(
validate_model_metadata(hub_path, file_path),
c("hub_validations", "list")
c("hub_validations")
)
})
10 changes: 5 additions & 5 deletions tests/testthat/test-validate_submission.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_that("validate_submission works", {
skip_submit_window_check = TRUE,
skip_check_config = TRUE
),
c("hub_validations", "list")
c("hub_validations")
)

# File with validation error ----
Expand All @@ -39,7 +39,7 @@ test_that("validate_submission works", {
skip_submit_window_check = TRUE,
skip_check_config = TRUE
),
c("hub_validations", "list")
c("hub_validations")
)

# Wrong submission location & missing data column (age_group)
Expand All @@ -58,7 +58,7 @@ test_that("validate_submission works", {
skip_submit_window_check = TRUE,
skip_check_config = TRUE
),
c("hub_validations", "list")
c("hub_validations")
)


Expand Down Expand Up @@ -88,7 +88,7 @@ test_that("validate_submission works", {
file_path = "team1-goodmodel/2022-10-08-team1-goodmodel.csv",
skip_submit_window_check = TRUE
),
c("hub_validations", "list")
c("hub_validations")
)
})

Expand Down Expand Up @@ -149,7 +149,7 @@ test_that("validate_submission fails when csv cannot be parsed according to sche
file_path = "hub-baseline/2023-05-01-hub-baseline.csv",
skip_submit_window_check = TRUE
)[["file_read"]],
c("check_error", "hub_check", "rlang_error", "error", "condition")
c("check_error")
)
})

Expand Down
Loading
Loading