Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: implement testing and benchmarking #12

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
^\.github$
^rdgidb\.Rproj$
^\.Rproj\.user$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.Rproj.user
9 changes: 9 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ License: use_mit_license()
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Imports:
data.table,
httr,
tidyr
Suggests:
devtools,
microbenchmark,
testthat (>= 3.0.0)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by roxygen2: do not edit by hand

2 changes: 1 addition & 1 deletion dgidb.R → R/dgidb.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library(tidyverse)
library(tidyr)
library(data.table)
library(httr)

Expand Down
17 changes: 17 additions & 0 deletions rdgidb.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
Encoding: UTF-8

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
17 changes: 0 additions & 17 deletions test-dgidb.R

This file was deleted.

12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(devtools)

devtools::load_all()
devtools::test()
38 changes: 38 additions & 0 deletions tests/testthat/test-dgidb.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
library(testthat)
library(microbenchmark)

test_that("Test: Get Gene Interactions", {
gene_data <- get_interactions(c("BRAF", "PDGFRA"))
expect_no_error(gene_data)
print("Performing Benchmark on: Get Gene Interactions...")
benchmark_results <- microbenchmark(
get_interactions(c("BRAF", "PDGFRA")),
times = 10
)
print(benchmark_results)
})

test_that("Test: Get Drug Interactions", {
drug_data <- get_interactions(c("SUNITINIB", "ZALCITABINE"), search = "drugs")
expect_no_error(drug_data)
print("Performing Benchmark on: Get Drug Interactions...")
benchmark_results <- microbenchmark(
get_interactions(c("SUNITINIB", "ZALCITABINE"), search = "drugs"),
times = 10
)
print(benchmark_results)
})

test_that("Test: Get Drug Applications", {
drug_app_data <- get_drug_applications(
c("SUNITINIB", "EXENATIDE"),
use_processing = TRUE
)
expect_no_error(drug_app_data)
print("Performing Benchmark on: Get Drug Applications...")
benchmark_results <- microbenchmark(
get_drug_applications(c("SUNITINIB", "EXENATIDE"), use_processing = TRUE),
times = 10
)
print(benchmark_results)
})