Skip to content

Commit

Permalink
test: add xwalk function tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elipousson committed Jan 4, 2024
1 parent f9da9d8 commit 98a7e4c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/xwalk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# xwalk functions work

Code
acs_data_interp
Output
# A tibble: 1 x 22
NAME variable column_id table_id estimate moe perc_estimate perc_moe
<chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 9504 B01003_001 B01003001 B01003 2748 272 NA NA
# i 14 more variables: geography <chr>, table_title <chr>,
# simple_table_title <chr>, subject_area <chr>, universe <chr>,
# denominator_column_id <chr>, topics <chr>, line_number <dbl>,
# column_title <chr>, indent <dbl>, parent_column_id <chr>,
# denominator_estimate <dbl>, denominator_moe <dbl>,
# denominator_column_title <chr>

34 changes: 34 additions & 0 deletions tests/testthat/test-xwalk.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
test_that("xwalk functions work", {
skip_if_not_installed("sf")

block_xwalk <- make_block_xwalk(
state = "MD",
county = "Kent County"
)

expect_s3_class(block_xwalk, "sf")

area_xwalk <- make_area_xwalk(
area = sf::st_buffer(xwalk[1,], dist = 5000),
block_xwalk = block_xwalk
)

expect_s3_class(area_xwalk, "tbl_df")

acs_data <- get_acs_tables(
geography = "tract",
state = "MD",
county = "Kent County",
table = "B01003",
year = 2022
)

acs_data_interp <- use_area_xwalk(
data = acs_data,
area_xwalk = area_xwalk
)

expect_snapshot(
acs_data_interp
)
})

0 comments on commit 98a7e4c

Please sign in to comment.