Skip to content

Commit

Permalink
Merge pull request #16 from ethanwhite/test-updates
Browse files Browse the repository at this point in the history
Use r-lib actions for install and check
  • Loading branch information
ethanwhite authored Jul 13, 2024
2 parents a421062 + 7c1d229 commit 85f0b63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ jobs:
run: |
reticulate::install_miniconda()
reticulate::py_install('DeepForest', pip=TRUE)
install.packages('deepforestr')
shell: Rscript {0}
- name: Check
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}
- name: Build and check deepforester
uses: r-lib/actions/check-r-package@v2
40 changes: 12 additions & 28 deletions tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,33 @@ library(testthat)

context("integration tests for DeepForest in R")

test_that("deepforest model is installed", {
# Python package not installed on CRAN

skip_on_cran()
skip_if_no_deepforest <- function() {
deepforest_avail <- reticulate::py_module_available("deepforest")
if (!deepforest_avail)
skip("deepforest not available for testing")
}

test_that("deepforest model is installed", {
skip_if_no_deepforest()
deepforest_available = reticulate::py_module_available("deepforest")
expect_identical(deepforest_available, TRUE)
})

test_that("deepforest model exists when loaded", {

# Python package not installed on CRAN

skip_on_cran()

skip_if_no_deepforest()
model = df_model()
expect_type(model, "closure")

})

test_that("use_release model exists when loaded", {

# Python package not installed on CRAN

skip_on_cran()

skip_if_no_deepforest()
model = df_model()
model$use_release()
expect_type(model, "closure")

})

test_that("image prediction works", {

# Python package not installed on CRAN

skip_on_cran()

expect

skip_if_no_deepforest()
model = df_model()
model$use_release()
image_path = get_data("OSBS_029.png")
Expand All @@ -51,9 +37,7 @@ test_that("image prediction works", {
})

test_that("training works", {

skip_on_cran()

skip_if_no_deepforest()
model = df_model()
model$use_release()
annotations_file = get_data("testfile_deepforest.csv")
Expand All @@ -65,4 +49,4 @@ test_that("training works", {
model$create_trainer()
model$trainer$fit(model)
expect_type(model, "closure")
})
})

0 comments on commit 85f0b63

Please sign in to comment.