Skip to content

Randomization endpoint should not respond with internall server error on data validation #70

Description

@lwalejko

This test case suggests that there is unhandled validation case for this endpoint:

test_that("request with patient that is assigned an arm at entry", {
response <- request(api_url) |>
req_url_path("study", "minimisation_pocock") |>
req_method("POST") |>
req_body_json(
data = list(
identifier = "ABC-X",
name = "Study ABC-X",
method = "var",
p = 0.85,
arms = list(
"placebo" = 1,
"active" = 1
),
covariates = list(
sex = list(
weight = 1,
levels = c("female", "male")
),
weight = list(
weight = 1,
levels = c("up to 60kg", "61-80 kg", "81 kg or more")
)
)
)
) |>
req_perform()
response_body <-
response |>
resp_body_json()
response_current_state <-
tryCatch(
{
request(api_url) |>
req_url_path("study", response_body$study$id, "patient") |>
req_method("POST") |>
req_body_json(
data = list(
current_state =
tibble::tibble(
"sex" = c("female", "male"),
"weight" = c("61-80 kg", "81 kg or more"),
"arm" = c("placebo", "control")
)
)
) |>
req_perform()
},
error = function(e) e
)
testthat::expect_equal(
response_current_state$status, 500,
label = "HTTP status code"
)
})

We should always validate input data in a way that will prevent the app from returning Internal Server Errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions