Skip to content

Commit f2152ae

Browse files
committed
Unwind taxstats
1 parent 4ca62ab commit f2152ae

File tree

8 files changed

+18
-38
lines changed

8 files changed

+18
-38
lines changed

R/sample_files.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ CLEAR_ENV <- function() {
1717
rm(list = ls(envir = sf_env), envir = sf_env)
1818
}
1919

20+
skip_if_not <- function(...) {
21+
if (requireNamespace("testthat", quietly = TRUE)) {
22+
testthat::skip_if_not(...)
23+
}
24+
}
25+
2026
skip_without_sample_files <- function(file = NULL) {
2127
if (requireNamespace("testthat", quietly = TRUE)) {
2228
if (dir.exists(tax_dir())) {

man/apply_super_caps_and_div293.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/inverse_average_rate.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model_new_caps_and_div293.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_model_income_tax.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_that("Error handling", {
2222

2323

2424

25-
original <- income_tax(sample_file_1314$Taxable_Income, "2013-14", .dots.ATO = copy(sample_file_1314))
25+
original <- income_tax(sample_file_1314$Taxable_Income, "2013-14", .dots.ATO = copy(.sample_file_1314()))
2626

2727
new_tax <- model_income_tax(sample_file_1314_copy,
2828
baseline_fy = "2013-14",
@@ -246,9 +246,9 @@ test_that("Medicare options", {
246246
skip_on_circleci(2)
247247

248248
sample_file_1314_copy <- copy(.sample_file_1314())
249-
original <- income_tax(sample_file_1314$Taxable_Income,
249+
original <- income_tax(sample_file_1314_copy$Taxable_Income,
250250
fy.year = "2013-14",
251-
.dots.ATO = copy(sample_file_1314))
251+
.dots.ATO = copy(sample_file_1314_copy))
252252

253253
expect_warning(model_income_tax(sample_file_1314_copy,
254254
baseline_fy = "2013-14",
@@ -258,7 +258,7 @@ test_that("Medicare options", {
258258
regexp = "medicare_levy_upper_threshold = 25677")
259259

260260
sample_file_1314_if_2pc_ML <-
261-
sample_file_1314 %>%
261+
sample_file_1314_copy %>%
262262
copy %>%
263263
.[, old_tax := income_tax(Taxable_Income, "2013-14", .dots.ATO = .)] %>%
264264
.[, new_tax := model_income_tax(sample_file_1314_copy,

tests/testthat/test_total_receipts.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
context("Tax receipts")
22

33
test_that("income_tax on individual sample file reflect historical collections", {
4-
skip_if_not_installed("taxstats")
54
# testthat::skip_on_travis()
65

76
# True value of personal income tax receipts was $159.021 billion
@@ -14,7 +13,7 @@ test_that("income_tax on individual sample file reflect historical collections",
1413

1514
# basic taxable income to tax
1615
test1 <-
17-
sample_file_1213 %>%
16+
.sample_file_("1213") %>%
1817
copy %>%
1918
.[, tax0 := income_tax(Taxable_Income, "2012-13")] %>%
2019
.[, tax1 := income_tax(Taxable_Income, "2012-13", age = 42)]
@@ -45,9 +44,9 @@ test_that("income_tax on individual sample file reflect historical collections",
4544
setnames(old = names(.), new = c("age_range", "age")) %>%
4645
.[, age := sub("\\sto.*$", "", age)] %>%
4746
setkey(age_range)
48-
setkey(sample_file_1213, age_range)
47+
setkey(.sample_file_("1213"), age_range)
4948
tax.collection <-
50-
sample_file_1213[age_decoder] %$%
49+
.sample_file_("1213")[age_decoder] %$%
5150
{
5251
sum(income_tax(income = Taxable_Income, fy.year = "2012-13", age = as.integer(age))) * 50
5352
}

tests/testthat/test_utils.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
context("utils")
22

33
test_that("unselect_", {
4-
skip_if_not_installed("taxstats")
5-
library(taxstats)
6-
y <- sample_file_1314 %>% copy %>% unselect_(.dots = "Sw_amt")
4+
y <- data.table(x = 1, Sw_amt = 2) %>% unselect_(.dots = "Sw_amt")
75
expect_false("Sw_amt" %in% names(y))
86
})
97

tests/testthat/test_wout_taxstats.R

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)