tests/testthat/test-assign_status.R

context("assign_status")


assessed.df <- expand.grid(
  data.frame(
    within_period = c(TRUE, FALSE),
    min_years_samples = c(TRUE, FALSE),
    wqs_violation = c(TRUE, FALSE),
    wqs_75_violation = c(TRUE, FALSE),
    min_violations_year = c(TRUE, FALSE),
    tmdl = c(TRUE, FALSE),
    ltco_rest_plan = c(TRUE, FALSE),
    pollutant = c(TRUE, FALSE))
)

assigned.df <- assign_status(assessed.df)

test_that("assign_status() returns the expected error messages when required names are missing.", {
  for(col.i in seq_along(assessed.df)) {
    expect_error(assign_status(assessed.df[-col.i]),
                 paste(".data must include name(s):",
                       names(assessed.df[col.i])),
                 fixed = TRUE)
  }
})

test_that("assign_status() does not return any ERROR in the asssessment col.", {
  expect_false(any(assigned.df$assessment %in% "ERROR"))
})

test_that("", {
  expect_false(
    unique(assigned.df[grepl("Manual Review Required", assigned.df$assessment), "within_period"])
  )
})
BWAM/stayCALM documentation built on May 21, 2020, 3:24 p.m.