From ffdd364b8f895cd9b683eecc13dff6f21c5518c6 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Sat, 5 Feb 2022 16:30:52 +0000 Subject: [PATCH] test processing reversion --- R/processing.R | 9 ++++----- tests/testthat/custom_tests/mock_data.R | 1 - tests/testthat/test-processing.R | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/R/processing.R b/R/processing.R index 914910a2..81c5ec4f 100644 --- a/R/processing.R +++ b/R/processing.R @@ -250,8 +250,7 @@ process_internal <- function(clean_data, level, group_vars, group_vars_standard, "cases_total", "deaths_total", "recovered_total", "hosp_total", "tested_total" ) - )) %>% - ungroup() + )) } else { dat <- dat %>% drop_na(.data$date) %>% @@ -264,11 +263,11 @@ process_internal <- function(clean_data, level, group_vars, "hosp_new", "hosp_total", "tested_new", "tested_total" )), everything() - ) %>% - ungroup() %>% - arrange(.data$date, all_of(group_vars_standard[1])) + ) } + dat <- ungroup(dat) + if (localise) { old <- names(group_vars) names(old) <- group_vars diff --git a/tests/testthat/custom_tests/mock_data.R b/tests/testthat/custom_tests/mock_data.R index 004dde6e..006cffdf 100644 --- a/tests/testthat/custom_tests/mock_data.R +++ b/tests/testthat/custom_tests/mock_data.R @@ -239,7 +239,6 @@ get_expected_data_for_complete_cumulative_columns_test <- function() { # manually add cumulative cases to get expected data full_data_with_cum_cases_filled <- partial_data %>% - dplyr::group_by(level_1_region, level_1_region_code) %>% covidregionaldata:::fill_empty_dates_with_na() full_data_with_cum_cases_filled <- dplyr::arrange(full_data_with_cum_cases_filled, level_1_region, date) diff --git a/tests/testthat/test-processing.R b/tests/testthat/test-processing.R index ee429e67..e13ce6ad 100644 --- a/tests/testthat/test-processing.R +++ b/tests/testthat/test-processing.R @@ -80,13 +80,12 @@ test_that("fill_empty_dates_with_na fills empty dates with NA", { expected_data <- get_expected_data_for_fill_empty_dates_with_na_test() # partial data deletes some rows (i.e. gets rid of some dates - all the ones # with NA in cases) - expected_data <- expected_data %>% - dplyr::group_by(level_1_region, level_1_region_code) + expected_data <- expected_data partial_data <- expected_data[-c(6:9), ] expect_equal( fill_empty_dates_with_na(partial_data), - dplyr::arrange(expected_data, level_1_region, date) + expected_data ) expected_data <- dplyr::mutate( expected_data, @@ -101,7 +100,7 @@ test_that("fill_empty_dates_with_na fills empty dates with NA", { partial_data <- expected_data[-c(6:9), ] expect_equal( fill_empty_dates_with_na(partial_data), - dplyr::arrange(expected_data, level_2_region, date) + expected_data ) })