tests/testthat/test_fetch_debate.R

# Test functions in fetch_debate.R
# Imports ---------------------------------------------------------------------

source("tests/testthat/validate.R")

# Mocks -----------------------------------------------------------------------
mock_download_csv <- function(url) {
  read("fetch_debate_mocks_data")
}

# Tests -----------------------------------------------------------------------

test_that("fetch_debate processes results correctly.", {

  mockery::stub(fetch_debate, "download_csv", mock_download_csv)

  cols <- c(
    "type",
    "ref",
    "date",
    "title",
    "content",
    "member",
    "member_party",
    "department",
    "legislature",
    "place",
    "subject",
    "legislation",
    "procedure",
    "web_location",
   )

  obs <- fetch_debate("Agricultural Exports from Australia: Tariffs", "2021-05-27", 21, 22)
  exp <- readRDS("tests/testthat/data/fetch_debate_data.RData")
  compare_obs_exp(obs, exp, cols, "ref")
})

# ERROR: ARGUMENT 15 IS EMPTY
eliseuberoi/clcontributions documentation built on June 9, 2021, 9:24 p.m.