Skip to content

Commit

Permalink
portable event-read
Browse files Browse the repository at this point in the history
ref #542
  • Loading branch information
wibeasley committed Oct 13, 2024
1 parent 012b003 commit b911ce9
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions tests/testthat/test-event-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ retrieve_expected_events <- function(path) {
if (!file.exists(full_path))
stop("The expected file `", full_path, "` was not found.") # nocov

col_types <- readr::cols(
col_types <- readr::cols_only(
event_name = readr::col_character(),
arm_num = readr::col_integer(),
unique_event_name = readr::col_character(),
custom_event_label = readr::col_character(),
event_id = readr::col_integer()
custom_event_label = readr::col_character()#,
# event_id = readr::col_integer()
)

full_path %>%
Expand All @@ -22,8 +22,8 @@ empty_data_frame <-
event_name = character(0),
arm_num = integer(0),
unique_event_name = character(0),
custom_event_label = character(0),
event_id = integer(0)
custom_event_label = character(0)#,
# event_id = integer(0)
)

test_that("Longitudinal Single Arm", {
Expand All @@ -41,6 +41,11 @@ test_that("Longitudinal Single Arm", {
verbose = FALSE
)

expect_true(all(!is.na(returned_object$data$event_id)))
expect_true(all(0 < returned_object$data$event_id))

returned_object$data$event_id <- NULL

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) #returned_object2$data$bmi<-NULL; returned_object2$data$age<-NULL;dput(returned_object2$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object2$raw_text)
Expand All @@ -63,6 +68,11 @@ test_that("Longitudinal Two Arms", {
verbose = FALSE
)

expect_true(all(!is.na(returned_object$data$event_id)))
expect_true(all(0 < returned_object$data$event_id))

returned_object$data$event_id <- NULL

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) #returned_object2$data$bmi<-NULL; returned_object2$data$age<-NULL;dput(returned_object2$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object2$raw_text)
Expand All @@ -84,6 +94,11 @@ test_that("Classic", {
)
})

expect_true(all(!is.na(returned_object$data$event_id)))
expect_true(all(0 < returned_object$data$event_id))

returned_object$data$event_id <- NULL

expect_equal(returned_object$data, expected=empty_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) #returned_object2$data$bmi<-NULL; returned_object2$data$age<-NULL;dput(returned_object2$data)
expect_equal(returned_object$status_code, expected=400L)
expect_equal(returned_object$raw_text, expected="ERROR: You cannot export events for classic projects", ignore_attr = TRUE) # dput(returned_object2$raw_text)
Expand All @@ -106,6 +121,11 @@ test_that("delete-multiple-arm", {
verbose = FALSE
)

expect_true(all(!is.na(returned_object$data$event_id)))
expect_true(all(0 < returned_object$data$event_id))

returned_object$data$event_id <- NULL

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) #returned_object2$data$bmi<-NULL; returned_object2$data$age<-NULL;dput(returned_object2$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object2$raw_text)
Expand All @@ -127,6 +147,11 @@ test_that("delete-single-arm", {
)
})

expect_true(all(!is.na(returned_object$data$event_id)))
expect_true(all(0 < returned_object$data$event_id))

returned_object$data$event_id <- NULL

expect_equal(returned_object$data, expected=empty_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) #returned_object2$data$bmi<-NULL; returned_object2$data$age<-NULL;dput(returned_object2$data)
expect_equal(returned_object$status_code, expected=400L)
expect_equal(returned_object$raw_text, expected="ERROR: You cannot export events for classic projects", ignore_attr = TRUE) # dput(returned_object2$raw_text)
Expand Down

0 comments on commit b911ce9

Please sign in to comment.