Skip to content

Commit

Permalink
Fixed unit tests to anticipate connexion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bgcarlisle committed Apr 8, 2022
1 parent 8a304ce commit 4304fe2
Show file tree
Hide file tree
Showing 29 changed files with 319 additions and 116 deletions.
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_contacts.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov contacts downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
jsonlite::fromJSON(version$contacts_data)$label[1],
"Central Contact Person:"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
jsonlite::fromJSON(version$contacts_data)$label[1],
"Central Contact Person:"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_criteria.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov criteria downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$criteria,
jsonlite::toJSON("Inclusion Criteria (MCI patients):\n\nright handedness\namnestic and amnestic plus MCI with:\nsubjective memory impairment;\nobjective memory difficulties, at least 1 SD below gender, age and education adjusted standard values;\nrelatively normal performance in other cognitive domains;\nno constraints in activities of daily livings\nage: 50-80 years\n\nExclusion Criteria:\n\nsevere internal or psychiatric disease\nepilepsy\nother severe neurological diseases, e.g. previous major stroke or brain tumor\nDMS-IV manifest dementia\ncontraindication for MRT (claustrophobia, metallic implants, tattoos)")
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$criteria,
jsonlite::toJSON("Inclusion Criteria (MCI patients):\n\nright handedness\namnestic and amnestic plus MCI with:\nsubjective memory impairment;\nobjective memory difficulties, at least 1 SD below gender, age and education adjusted standard values;\nrelatively normal performance in other cognitive domains;\nno constraints in activities of daily livings\nage: 50-80 years\n\nExclusion Criteria:\n\nsevere internal or psychiatric disease\nepilepsy\nother severe neurological diseases, e.g. previous major stroke or brain tumor\nDMS-IV manifest dementia\ncontraindication for MRT (claustrophobia, metallic implants, tattoos)")
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_enrol.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov enrolment downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$enrol,
"22 [Anticipated]"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$enrol,
"22 [Anticipated]"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_gender.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov gender-based downloads correctly", {
version <- clinicaltrials_gov_version("NCT05306145", 1)
expect_equal(
version$gender_based,
"Yes"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$gender_based,
"Yes"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_max_age.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov maximum age downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$max_age,
"80"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$max_age,
"80"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_min_age.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov minimum age downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$min_age,
"50"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$min_age,
"50"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_om_data.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov outcome measures downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
jsonlite::fromJSON(version$om_data)$content[1],
"Performance in LOCATO task (Visual-spatial learning and memory) after a combination of intensive visual-spatial training and tDCS\n[ Time Frame: immediately after end of a 3-day period of training in tDCS condition vs sham condition ]\n\nInvestigation whether the combination of intensive visual-spatial training (LOCATO task) and tDCS leads to improvement of visual-spatial learning and memory measured by performance in LOCATO task after end of a 3 day period of training compared to sham stimulation."
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
jsonlite::fromJSON(version$om_data)$content[1],
"Performance in LOCATO task (Visual-spatial learning and memory) after a combination of intensive visual-spatial training and tDCS\n[ Time Frame: immediately after end of a 3-day period of training in tDCS condition vs sham condition ]\n\nInvestigation whether the combination of intensive visual-spatial training (LOCATO task) and tDCS leads to improvement of visual-spatial learning and memory measured by performance in LOCATO task after end of a 3 day period of training compared to sham stimulation."
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_ostatus.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov overall status downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$ostatus,
"Recruiting"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$ostatus,
"Recruiting"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_pcdate.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov primary completion date downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$pcdate,
"2015-08-01"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$pcdate,
"2015-08-01"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_pcdate_precision.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov primary completion date precision downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$pcdate_precision,
"month"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$pcdate_precision,
"month"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_pcdatetype.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov primary completion date type downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$pcdatetype,
"Anticipated"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$pcdatetype,
"Anticipated"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_sex.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov sex downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$sex,
"All"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$sex,
"All"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_sponsor_data.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov contacts downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
jsonlite::fromJSON(version$sponsor_data)$content[1],
"Charite University, Berlin, Germany"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
jsonlite::fromJSON(version$sponsor_data)$content[1],
"Charite University, Berlin, Germany"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_startdate.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov start date downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$startdate,
"2014-03-01"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$startdate,
"2014-03-01"
)
}
})
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov start date precision downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$startdate_precision,
"month"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$startdate_precision,
"month"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-clinicaltrials_gov_version_volunteers.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("ClinicalTrials.gov 'accepts healthy volunteers' downloads correctly", {
version <- clinicaltrials_gov_version("NCT02110043", 1)
expect_equal(
version$accepts_healthy_volunteers,
"No"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$accepts_healthy_volunteers,
"No"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-drks_de_version_closingdate.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("DRKS closing date downloads correctly", {
version <- drks_de_version("DRKS00004013", 7)
expect_equal(
version$closingdate,
"2014-09-01"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$closingdate,
"2014-09-01"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-drks_de_version_contacts.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("DRKS contacts download correctly", {
version <- drks_de_version("DRKS00005219", 1)
expect_equal(
jsonlite::fromJSON(version$contacts)$label[1],
"Primary Sponsor"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
jsonlite::fromJSON(version$contacts)$label[1],
"Primary Sponsor"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-drks_de_version_enrolno.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("DRKS enrolment number downloads correctly", {
version <- drks_de_version("DRKS00004013", 7)
expect_equal(
version$enrolno,
"300"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$enrolno,
"300"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-drks_de_version_enroltype.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("DRKS enrolment type downloads correctly", {
version <- drks_de_version("DRKS00005219", 1)
expect_equal(
version$enroltype,
"Actual"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
version$enroltype,
"Actual"
)
}
})
15 changes: 11 additions & 4 deletions tests/testthat/test-drks_de_version_exclusion_criteria.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
test_that("DRKS inclusion criteria download correctly", {
version <- drks_de_version("DRKS00005219", 1)
expect_equal(
jsonlite::fromJSON(version$exclusion_criteria)[2],
"- Known hypersensitivity to the study medication\n- All contraindications to the study medication: arrhythmia, hyperthyroidism , glaucoma , pheochromocytoma , congestive heart failure , diabetes mellitus, known liver and kidney dysfunction, vascular disease , angina, haemodynamically significant congenital heart disease , cardiomyopathy , myocardial infarction, channelopathies, arterial hypertension , cerebrovascular diseases , such as cerebral aneurysm , vascular abnormalities , including vasculitis and stroke.\n- Participation in other clinical trials during or within one month prior to this clinical trial\n- Medical or psychological circumstances that may endanger the proper conduct of the trial\n- Existing serious somatic diseases, even if they are not covered by the contraindications according to product information\n- Existing psychiatric disorders and psychiatric disorders in prehistory\n- Smoker or ex-smoker for less than 5 years\n- Regular caffeine consumption > 4 cups per day\n- Subjects with irregular day -night rhythm (eg shift workers )\n- Unwillingness to the storage and disclosure of pseudonymous data as part of the clinical trial\n- Accommodation in an institution by court or administrative order (according to AMG § 40 (1) 4 )\n- MR contraindications ( eg pacemakers , metallic or electronic implants , metallic splinters , tinnitus, surgical clips )\n"
)
if (version[1] == "Error") {
expect_equal(
version[1],
"Error"
)
} else {
expect_equal(
jsonlite::fromJSON(version$exclusion_criteria)[2],
"- Known hypersensitivity to the study medication\n- All contraindications to the study medication: arrhythmia, hyperthyroidism , glaucoma , pheochromocytoma , congestive heart failure , diabetes mellitus, known liver and kidney dysfunction, vascular disease , angina, haemodynamically significant congenital heart disease , cardiomyopathy , myocardial infarction, channelopathies, arterial hypertension , cerebrovascular diseases , such as cerebral aneurysm , vascular abnormalities , including vasculitis and stroke.\n- Participation in other clinical trials during or within one month prior to this clinical trial\n- Medical or psychological circumstances that may endanger the proper conduct of the trial\n- Existing serious somatic diseases, even if they are not covered by the contraindications according to product information\n- Existing psychiatric disorders and psychiatric disorders in prehistory\n- Smoker or ex-smoker for less than 5 years\n- Regular caffeine consumption > 4 cups per day\n- Subjects with irregular day -night rhythm (eg shift workers )\n- Unwillingness to the storage and disclosure of pseudonymous data as part of the clinical trial\n- Accommodation in an institution by court or administrative order (according to AMG § 40 (1) 4 )\n- MR contraindications ( eg pacemakers , metallic or electronic implants , metallic splinters , tinnitus, surgical clips )\n"
)
}
})
Loading

0 comments on commit 4304fe2

Please sign in to comment.