Skip to content

Commit

Permalink
upgrade to dbplyr 2.4.0 and change unit tests of remote tables for Ra…
Browse files Browse the repository at this point in the history
…mses objects
  • Loading branch information
peterdutey committed Nov 19, 2023
1 parent ebd423f commit 9cd914a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 93 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Ramses
Type: Package
Title: R Package for Antimicrobial Stewardship & Surveillance
Version: 0.7.0
Version: 0.7.1
Authors@R: c(
person(given = "Peter",
family = "Dutey-Magni",
Expand Down Expand Up @@ -31,7 +31,7 @@ Imports:
DBI,
rlang,
dplyr (>= 1.1.0),
dbplyr (>= 2.3.2),
dbplyr (>= 2.4.0),
tidyselect (>= 1.2.0),
magrittr,
duckdb (>= 0.4.0),
Expand Down Expand Up @@ -59,11 +59,12 @@ Suggests:
R.utils,
comorbidity,
RPostgres,
gh (>= 1.3.0)
gh (>= 1.3.0),
vctrs
Remotes:
ramses-antibiotics/snomedizer
RdMacros: Rdpack
RoxygenNote: 7.2.0
RoxygenNote: 7.2.3
VignetteBuilder: knitr,rmarkdown
Collate:
'Ramses-deprecated.R'
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

# Ramses 0.7.1

*19 November 2023*

## Changed

- Now requires minimum `dbplyr` v2.4.0.
- Unit test maintenance required by `dbplyr` v2.4.0.

# Ramses 0.7.0

*11 April 2023*
Expand Down
144 changes: 55 additions & 89 deletions tests/testthat/test-objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,14 @@ test_that("Patient..interface_methods DuckDB", {
expect_equal(capture.output(patient_object)[1],
"Patient 99999999999 ")
# COMPUTE
expect_equal(
patient_object@record$lazy_query$x$x,
structure("patients", class = c("ident", "character"))
)
expect_is(patient_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(patient_object@record$lazy_query$x$x, "table"), "patients")

patient_object_computed <- compute(patient_object)

expect_true(
grepl("^dbplyr_",
as.character(
patient_object_computed@record$lazy_query$x
))
vctrs::field(patient_object_computed@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down Expand Up @@ -119,16 +117,14 @@ test_that("Patient..interface_methods Postgres", {
expect_equal(capture.output(patient_object)[1],
"Patient 99999999999 ")
# COMPUTE
expect_equal(
patient_object@record$lazy_query$x$x,
structure("patients", class = c("ident", "character"))
)
expect_is(patient_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(patient_object@record$lazy_query$x$x, "table"), "patients")

patient_object_computed <- compute(patient_object)

expect_true(
grepl("^dbplyr_",
as.character(
patient_object_computed@record$lazy_query$x
))
vctrs::field(patient_object_computed@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down Expand Up @@ -278,16 +274,16 @@ test_that("MedicationRequest..interface_methods DuckDB", {
)

# COMPUTE
expect_is(med_req_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(
med_req_object@record$lazy_query$x$x,
structure("drug_prescriptions", class = c("ident", "character"))
vctrs::field(med_req_object@record$lazy_query$x$x, "table"),
"drug_prescriptions"
)

med_req_object_computed <- compute(med_req_object)
expect_true(
grepl("^dbplyr_",
as.character(
med_req_object_computed@record$lazy_query$x
))
vctrs::field(med_req_object_computed@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down Expand Up @@ -381,16 +377,13 @@ test_that("MedicationRequest..interface_methods Postgres", {
)

# COMPUTE
expect_equal(
med_req_object@record$lazy_query$x$x,
structure("drug_prescriptions", class = c("ident", "character"))
)
expect_is(med_req_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(med_req_object@record$lazy_query$x$x, "table"), "drug_prescriptions")

med_req_object_computed <- compute(med_req_object)
expect_true(
grepl("^dbplyr_",
as.character(
med_req_object_computed@record$lazy_query$x
))
vctrs::field(med_req_object_computed@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down Expand Up @@ -533,38 +526,31 @@ test_that("TherapyEpisode..interface_methods DuckDB", {
)

# COMPUTE
expect_equal(
therapy_object@record$lazy_query$x$x,
structure("drug_therapy_episodes", class = c("ident", "character"))
)
expect_is(therapy_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(therapy_object@record$lazy_query$x$x, "table"),
"drug_therapy_episodes")
therapy_object_computed <- compute(therapy_object)
expect_true(
grepl("^dbplyr_",
as.character(
therapy_object_computed@record$lazy_query$x
))
)
expect_equal(
therapy_object_multi@record$lazy_query$x$x,
structure("drug_therapy_episodes", class = c("ident", "character"))
vctrs::field(therapy_object_computed@record$lazy_query$x, "table"))
)

expect_is(therapy_object_multi@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(therapy_object_multi@record$lazy_query$x$x, "table"),
"drug_therapy_episodes")
therapy_object_multi_computed <- compute(therapy_object_multi)
expect_true(
grepl("^dbplyr_",
as.character(
therapy_object_multi_computed@record$lazy_query$x
))
)
expect_equal(
therapy_object_multi4@record$lazy_query$x$x,
structure("drug_therapy_episodes", class = c("ident", "character"))
vctrs::field(therapy_object_multi_computed@record$lazy_query$x, "table"))
)

expect_is(therapy_object_multi4@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(therapy_object_multi4@record$lazy_query$x$x, "table"),
"drug_therapy_episodes")
therapy_object_multi_computed4 <- compute(therapy_object_multi4)
expect_true(
grepl("^dbplyr_",
as.character(
therapy_object_multi_computed4@record$lazy_query$x
))
vctrs::field(therapy_object_multi_computed4@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down Expand Up @@ -699,38 +685,28 @@ test_that("TherapyEpisode..interface_methods Postgres", {
)

# COMPUTE
expect_equal(
therapy_object@record$lazy_query$x$x,
structure("drug_therapy_episodes", class = c("ident", "character"))
)
expect_is(therapy_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(therapy_object@record$lazy_query$x$x, "table"), "drug_therapy_episodes")
therapy_object_computed <- compute(therapy_object)
expect_true(
grepl("^dbplyr_",
as.character(
therapy_object_computed@record$lazy_query$x
))
)
expect_equal(
therapy_object_multi@record$lazy_query$x$x,
structure("drug_therapy_episodes", class = c("ident", "character"))
vctrs::field(therapy_object_computed@record$lazy_query$x, "table"))
)

expect_is(therapy_object_multi@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(therapy_object_multi@record$lazy_query$x$x, "table"), "drug_therapy_episodes")
therapy_object_multi_computed <- compute(therapy_object_multi)
expect_true(
grepl("^dbplyr_",
as.character(
therapy_object_multi_computed@record$lazy_query$x
))
)
expect_equal(
therapy_object_multi4@record$lazy_query$x$x,
structure("drug_therapy_episodes", class = c("ident", "character"))
vctrs::field(therapy_object_multi_computed@record$lazy_query$x, "table"))
)

expect_is(therapy_object_multi4@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(therapy_object_multi4@record$lazy_query$x$x, "table"), "drug_therapy_episodes")
therapy_object_multi_computed4 <- compute(therapy_object_multi4)
expect_true(
grepl("^dbplyr_",
as.character(
therapy_object_multi_computed4@record$lazy_query$x
))
vctrs::field(therapy_object_multi_computed4@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down Expand Up @@ -898,38 +874,28 @@ test_that("Encounter..interface_methods DuckDB", {
)

# COMPUTE
expect_equal(
encounter_object@record$lazy_query$x$x,
structure("inpatient_episodes", class = c("ident", "character"))
)
expect_is(encounter_object@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(encounter_object@record$lazy_query$x$x, "table"), "inpatient_episodes")
encounter_object_computed <- compute(encounter_object)
expect_true(
grepl("^dbplyr_",
as.character(
encounter_object_computed@record$lazy_query$x
))
)
expect_equal(
encounter_object_multi@record$lazy_query$x$x,
structure("inpatient_episodes", class = c("ident", "character"))
vctrs::field(encounter_object_computed@record$lazy_query$x, "table"))
)

expect_is(encounter_object_multi@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(encounter_object_multi@record$lazy_query$x$x, "table"), "inpatient_episodes")
encounter_object_multi_computed <- compute(encounter_object_multi)
expect_true(
grepl("^dbplyr_",
as.character(
encounter_object_multi_computed@record$lazy_query$x
))
)
expect_equal(
encounter_object_multi5@record$lazy_query$x$x,
structure("inpatient_episodes", class = c("ident", "character"))
vctrs::field(encounter_object_multi_computed@record$lazy_query$x, "table"))
)

expect_is(encounter_object_multi5@record$lazy_query$x$x, "dbplyr_table_ident")
expect_equal(vctrs::field(encounter_object_multi5@record$lazy_query$x$x, "table"), "inpatient_episodes")
encounter_object_multi5_computed <- compute(encounter_object_multi5)
expect_true(
grepl("^dbplyr_",
as.character(
encounter_object_multi5_computed@record$lazy_query$x
))
vctrs::field(encounter_object_multi5_computed@record$lazy_query$x, "table"))
)

# COLLECT
Expand Down

0 comments on commit 9cd914a

Please sign in to comment.