tests/testthat/test_pcr_utils.R

# test_pcr_utils.R
library(magrittr)
context("test_find_plates")

d <- system.file("extdata", "find_plates_testfile.xlsx",
                 package='assayr2') %>%
  openxlsx::read.xlsx(skipEmptyRows = FALSE,
                      skipEmptyCols = FALSE,
                      colNames = FALSE)

res <- assayr2::find_plates(d)

test_that("correct number of plates found",
          expect_equal(length(res[[1]]), 2)
)

test_that("sample identifiers are mapped to the correct well", {
         # Checking a few random wells
         expect_equal(dplyr::filter(res[[1]][[1]], row == 'A',
                                    column == '7') %>% .$content,
                      '13')
         expect_equal(dplyr::filter(res[[1]][[1]], row == 'B',
                                    column == '9') %>% .$content,
                      '51')
         expect_equal(dplyr::filter(res[[1]][[2]], row == 'E',
                                    column == '4') %>% .$content,
                      '21')
         expect_equal(dplyr::filter(res[[1]][[2]], row == 'C',
                                    column == '4') %>% .$content,
                      '19')
         }
)

test_that("wells with no sample identifiers are dropped", {
  # Checking a few random wells
  expect_equal(dplyr::filter(res[[1]][[1]], row == 'F',
                             column == '9') %>% nrow,
               0)
  }
)

rm(d, res)
detach("package:magrittr")
hemoshear/assayr2 documentation built on Nov. 8, 2019, 6:13 p.m.