tests/testthat/test-get_top20_candidate_of_FinancialCategory.R

context("get_top20_candidate_of_FinancialCategory")

test_that("expected errors", {
  expect_warning(expect_error(get_top20_candidate_of_FinancialCategory('pac-total', 1995), "Incorrect cycle"), "Cycle should be four-digit year larger than 1996")
  expect_error(get_top20_candidate_of_FinancialCategory('pac-', 1996), "Incorrect Category")
})

test_that("expected lengths", {
  categories <- c('candidate-loan', 'contribution-total', 'debts-owed', 'disbursements-total', 'end-cash', 'individual-total', 
                  'pac-total', 'receipts-total', 'refund-total')
  expect_length(get_top20_candidate_of_FinancialCategory(categories[1], 1996), 6)
 
})

Try the ProPublicaR package in your browser

Any scripts or data that you put into this service are public.

ProPublicaR documentation built on Sept. 8, 2023, 5:53 p.m.