tests/testthat/test-02-tables.R

context("Tables")

olddir <- Sys.getenv("CONSTITUCION_BBDD_DIR")
Sys.setenv(CONSTITUCION_BBDD_DIR = normalizePath(file.path(getwd(), "constitucionabierta"),
                                          mustWork = FALSE
))

test_that("constitucion_datos returns tbl_df", {
  skip_on_cran()
  skip_if_not(constitucion_estado())
  
  expect_is(constitucion_bbdd(), "SQLiteConnection")
  
  for (t in c("ela", "participante")) {
    expect_is(constitucion_tabla(t), "tbl_df")
  }
})

test_that("constitucion_datos returns tbl_lazy", {
  skip_on_cran()
  skip_if_not(constitucion_estado())
  
  expect_is(constitucion_bbdd(), "SQLiteConnection")
  
  for (t in c("ela", "participante")) {
    expect_is(dplyr::tbl(constitucion_bbdd(), t), "tbl_lazy")
  }
})

Sys.setenv(CONSTITUCION_BBDD_DIR = olddir)
pachamaltese/constitucionabierta documentation built on Dec. 31, 2020, 1:11 a.m.