Skip to content

Commit

Permalink
Merge pull request #268 from OHDSI/cran
Browse files Browse the repository at this point in the history
skip some tests on CRAN
  • Loading branch information
ginberg authored Aug 31, 2024
2 parents 2d4e8ae + 351355e commit f2b53ca
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ if (dbms == "bigquery" && .Platform$OS.type == "windows") {
# oracle
if (dbms == "oracle") {
DatabaseConnector::downloadJdbcDrivers(dbms)
oracleConnectionDetails <- createConnectionDetails(
oracleConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = dbms,
user = Sys.getenv("CDM5_ORACLE_USER"),
password = URLdecode(Sys.getenv("CDM5_ORACLE_PASSWORD")),
Expand All @@ -148,7 +148,7 @@ if (dbms == "oracle") {
# postgres
if (dbms == "postgresql") {
DatabaseConnector::downloadJdbcDrivers(dbms)
pgConnectionDetails <- createConnectionDetails(
pgConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = dbms,
user = Sys.getenv("CDM5_POSTGRESQL_USER"),
password = URLdecode(Sys.getenv("CDM5_POSTGRESQL_PASSWORD")),
Expand All @@ -161,7 +161,7 @@ if (dbms == "postgresql") {
# redshift
if (dbms == "redshift") {
DatabaseConnector::downloadJdbcDrivers(dbms)
redshiftConnectionDetails <- createConnectionDetails(
redshiftConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = dbms,
user = Sys.getenv("CDM5_REDSHIFT_USER"),
password = URLdecode(Sys.getenv("CDM5_REDSHIFT_PASSWORD")),
Expand Down Expand Up @@ -204,7 +204,7 @@ if (dbms == "spark") {
# sql server
if (dbms == "sql server") {
DatabaseConnector::downloadJdbcDrivers("sql server")
sqlServerConnectionDetails <- createConnectionDetails(
sqlServerConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = "sql server",
user = Sys.getenv("CDM5_SQL_SERVER_USER"),
password = URLdecode(Sys.getenv("CDM5_SQL_SERVER_PASSWORD")),
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-Aggregation.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# covr::file_report(covr::file_coverage("R/Aggregation.R", "tests/testthat/test-Aggregation.R"))

test_that("aggregateCovariates works", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
settings <- createCovariateSettings(useDemographicsAgeGroup = TRUE, useChads2Vasc = TRUE)
covariateData <- getDbCovariateData(
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-CompareCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test_that("Test stdDiff continuous variable computation", {
})

test_that("Test stdDiff binary variable computation", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
Eunomia::createCohorts(connectionDetails)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-CovariateData.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test_that("test CovariateData Class on Empty", {
})

test_that("test saveCovariateData error cases", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
saveFileTest <- tempfile("covDatSave")
settings <- createDefaultCovariateSettings()
Expand Down Expand Up @@ -95,6 +96,7 @@ test_that("test summary call for covariateData class", {
})

test_that("test filtering of covariates based on minCharacterizationMean", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
settings <- createDefaultCovariateSettings()
covariateData <- getDbCovariateData(
Expand Down Expand Up @@ -155,6 +157,7 @@ test_that("Test show method", {
})

test_that("getDbCovariateData cohortId warning", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
settings <- createDefaultCovariateSettings()
expect_warning(getDbCovariateData(
Expand All @@ -168,6 +171,7 @@ test_that("getDbCovariateData cohortId warning", {
})

test_that("getDbCovariateData settings list - check metaData", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
looCovSet <- FeatureExtraction:::.createLooCovariateSettings(useLengthOfObs = TRUE)
covariateSettingsList <- list(looCovSet, looCovSet)
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-GetCohortBasedCovariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ test_that("Cohort-based covariates: binary, non-aggregated on Eunomia", {
})

test_that("Cohort-based covariates: binary, aggregated on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedBinaryAggTest(
connection = eunomiaConnection,
Expand All @@ -496,6 +497,7 @@ test_that("Cohort-based covariates: binary, aggregated on Eunomia", {
})

test_that("Cohort-based covariates: binary, non-aggregated, temporal on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedBinaryNonAggTemporalTest(
connection = eunomiaConnection,
Expand All @@ -506,6 +508,7 @@ test_that("Cohort-based covariates: binary, non-aggregated, temporal on Eunomia"
})

test_that("Cohort-based covariates: binary, aggregated, temporal on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedBinaryAggTemporalTest(
connection = eunomiaConnection,
Expand All @@ -516,6 +519,7 @@ test_that("Cohort-based covariates: binary, aggregated, temporal on Eunomia", {
})

test_that("Cohort-based covariates: counts, non-aggregated on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedCountsNonAggTest(
connection = eunomiaConnection,
Expand All @@ -526,6 +530,7 @@ test_that("Cohort-based covariates: counts, non-aggregated on Eunomia", {
})

test_that("Cohort-based covariates: counts, aggregated on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedCountsAggTest(
connection = eunomiaConnection,
Expand All @@ -536,6 +541,7 @@ test_that("Cohort-based covariates: counts, aggregated on Eunomia", {
})

test_that("Cohort-based covariates: counts, non-aggregated, temporal on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedCountsNonAggTemporalTest(
connection = eunomiaConnection,
Expand All @@ -546,6 +552,7 @@ test_that("Cohort-based covariates: counts, non-aggregated, temporal on Eunomia"
})

test_that("Cohort-based covariates: counts, aggregated, temporal on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedCountsAggTemporalTest(
connection = eunomiaConnection,
Expand All @@ -556,6 +563,7 @@ test_that("Cohort-based covariates: counts, aggregated, temporal on Eunomia", {
})

test_that("Cohort-based covariates: counts, aggregated, using multiple cohort IDs on Eunomia", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
runCohortBasedCountsAggMultiCohortTest(
connection = eunomiaConnection,
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-GetCovariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ test_that("getDbCovariateData enforces specification of database details", {
})

test_that("getDbCovariateData CDM v4 not supported", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
expect_error(getDbCovariateData(
connectionDetails = eunomiaConnectionDetails,
Expand All @@ -83,6 +84,7 @@ test_that("getDbCovariateData cohortTableIsTemp tests when table name lacks # sy
})

test_that("getDbCovariateData cohortTableIsTemp tests when table name contains # symbol", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
result <- getDbCovariateData(
connection = eunomiaConnection,
Expand All @@ -95,6 +97,7 @@ test_that("getDbCovariateData cohortTableIsTemp tests when table name contains #
})

test_that("getDbCovariateData populationSize == 0 tests", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
expect_warning(getDbCovariateData(
connection = eunomiaConnection,
Expand All @@ -107,6 +110,7 @@ test_that("getDbCovariateData populationSize == 0 tests", {
})

test_that("Custom covariate builder", {
skip_on_cran()
# TODO: This test is probably good to run on all DB platforms
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
covariateSettings <- createCovariateSettings(
Expand All @@ -129,6 +133,7 @@ test_that("Custom covariate builder", {
})

test_that("getDbCovariateData care site from person tests", {
skip_on_cran()
# TODO: This test is probably good to run on all DB platforms
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))

Expand Down Expand Up @@ -171,6 +176,7 @@ test_that("getDbCovariateData care site from person tests", {
})

test_that("getDbCovariateData care site from visit_occurrence tests", {
skip_on_cran()
# TODO: This test is probably good to run on all DB platforms
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-GetCovariatesFromCohortAttributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test_that("getDbCohortAttrCovariatesData CDM v4 not supported check", {
})

test_that("getDbCohortAttrCovariatesData hasIncludedAttributes == 0", {
skip_on_cran()
# TODO: This test is probably good to run on all DB platforms
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
covariateSettings <- createCohortAttrCovariateSettings(
Expand All @@ -47,6 +48,7 @@ test_that("getDbCohortAttrCovariatesData hasIncludedAttributes == 0", {
})

test_that("getDbCohortAttrCovariatesData hasIncludedAttributes > 0", {
skip_on_cran()
# TODO: This test is probably good to run on all DB platforms
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
covariateSettings <- createCohortAttrCovariateSettings(
Expand Down Expand Up @@ -74,6 +76,7 @@ test_that("createCohortAttrCovariateSettings check", {
})

test_that("getDbCohortAttrCovariatesData cohortId warning", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
covariateSettings <- createCohortAttrCovariateSettings(
attrDatabaseSchema = eunomiaOhdsiDatabaseSchema,
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-GetCovariatesTemporalSequence.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test_that("getDbCovariateData works with createTemporalSequenceCovariateSettings

# Check backwards compatibility
test_that("Temporal Covariate Settings are backwards compatible", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))

# Temporal covariate settings created previously will not have
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-GetDefaultCovariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# covr::file_report(covr::file_coverage("R/GetDefaultCovariates.R", "tests/testthat/test-GetDefaultCovariates.R"))

test_that("Test exit conditions", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))

# covariateSettings object type
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-HelperFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test_that("Test helper functions for non-aggregated covariate data", {
})

test_that("Test helper functions for aggregated covariate data", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
expect_error(filterByCohortDefinitionId("blah", 1), "not of class CovariateData")

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-Table1.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ test_that("createTable1 works with categorical covariates", {


test_that("createTable1 works with continuous covariates", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))

settings <- createCovariateSettings(
Expand Down Expand Up @@ -142,6 +143,7 @@ test_that("createTable1 works with continuous covariates", {


test_that("createTable1 works with other covariates", {
skip_on_cran()
skip_if_not(dbms == "sqlite" && exists("eunomiaConnection"))
settings <- createCovariateSettings(
useDemographicsAgeGroup = TRUE,
Expand Down

0 comments on commit f2b53ca

Please sign in to comment.