From 4546511b64948491e151405d10ede0d2ae6b5be5 Mon Sep 17 00:00:00 2001 From: hsonne Date: Sat, 8 Jul 2023 16:06:42 +0200 Subject: [PATCH 1/9] Use ggplot2::aes() instead of aes_string() to get rid of "deprecated" warning in vignette --- vignettes/tutorial.Rmd | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd index e946b7be..0e53740e 100644 --- a/vignettes/tutorial.Rmd +++ b/vignettes/tutorial.Rmd @@ -53,9 +53,9 @@ also_available <- function(what, format, filename) { } ggplot2_date_value <- function(data, col) { - ggplot2::ggplot(data, mapping = ggplot2::aes_string( - x = "Datum", - y = "Messwert", + ggplot2::ggplot(data, mapping = ggplot2::aes( + x = Datum, + y = Messwert, col = col )) } @@ -167,10 +167,10 @@ title_text <- sprintf( g1 <- gwl_classified_only %>% dplyr::count(Klassifikation, Grundwasserspannung) %>% dplyr::mutate(percental_share = kwb.utils::percentage(n, nrow(gwl))) %>% - ggplot2::ggplot(ggplot2::aes_string( - x = "Klassifikation", - y = "percental_share", - fill = "Grundwasserspannung" + ggplot2::ggplot(ggplot2::aes( + x = Klassifikation, + y = percental_share, + fill = Grundwasserspannung )) + ggplot2::geom_bar(stat = "identity") + ggplot2::labs( From 1661c5374a09e251a5cf4a3f65c78b386a54910f Mon Sep 17 00:00:00 2001 From: hsonne Date: Sat, 8 Jul 2023 17:24:23 +0200 Subject: [PATCH 2/9] Use dplyr::all_of() to get rid of "deprecated" warning in vignette --- vignettes/tutorial.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd index 0e53740e..112d1600 100644 --- a/vignettes/tutorial.Rmd +++ b/vignettes/tutorial.Rmd @@ -217,7 +217,7 @@ gwl_classified_only_with_coords <- gwl_classified_only %>% ) %>% dplyr::left_join( stations_gwl_master %>% - dplyr::select("Nummer", rechtswert, hochwert) %>% + dplyr::select(dplyr::all_of(c("Nummer", rechtswert, hochwert))) %>% dplyr::rename(Messstellennummer = "Nummer"), by = "Messstellennummer" ) %>% From a262fd64082056254396d5c107ab6b9b8ef0d2fb Mon Sep 17 00:00:00 2001 From: hsonne Date: Sat, 8 Jul 2023 17:41:01 +0200 Subject: [PATCH 3/9] Use dplyr::all_of() to get rid of "deprecated" warning in vignette --- vignettes/groundwater.Rmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vignettes/groundwater.Rmd b/vignettes/groundwater.Rmd index d2c26378..859700ef 100644 --- a/vignettes/groundwater.Rmd +++ b/vignettes/groundwater.Rmd @@ -176,12 +176,12 @@ str(gw_data) # Helper functions to be reused in different data summaries select_main_columns <- function(data) { data %>% - dplyr::select( - .data$Messstellennummer, - .data$Parameter, - .data$Datum, - .data$Messwert - ) + dplyr::select(dplyr::all_of(c( + "Messstellennummer", + "Parameter", + "Datum", + "Messwert" + ))) } summarise_min_max_n_arrange <- function(data) { From c922c17759fb01f0666434cfd99e6bdd5916ab54 Mon Sep 17 00:00:00 2001 From: hsonne Date: Sat, 8 Jul 2023 17:52:22 +0200 Subject: [PATCH 4/9] Set argument ".groups" to get rid of warning --- vignettes/groundwater.Rmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vignettes/groundwater.Rmd b/vignettes/groundwater.Rmd index 859700ef..134aacf4 100644 --- a/vignettes/groundwater.Rmd +++ b/vignettes/groundwater.Rmd @@ -189,7 +189,8 @@ summarise_min_max_n_arrange <- function(data) { dplyr::summarise( date_min = min(.data$Datum), date_max = max(.data$Datum), - n = dplyr::n() + n = dplyr::n(), + .groups = "drop" ) %>% dplyr::arrange(dplyr::desc(.data$n)) } From 822d460874e048559c9404dcd26819565beb00de Mon Sep 17 00:00:00 2001 From: hsonne Date: Tue, 15 Aug 2023 12:11:42 +0200 Subject: [PATCH 5/9] Fix typo --- R/list_data_to_csv_or_zip.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/list_data_to_csv_or_zip.R b/R/list_data_to_csv_or_zip.R index 07e68279..d9455ae6 100644 --- a/R/list_data_to_csv_or_zip.R +++ b/R/list_data_to_csv_or_zip.R @@ -24,7 +24,7 @@ list_data_to_csv_or_zip <- function(data_list, file_prefix, to_zip) filename <- ifelse(to_zip, filename_zip, filename_csv) kwb.utils::catAndRun( - messageText = sprintf("Writting '%s'", filename), + messageText = sprintf("Writing '%s'", filename), expr = { file <- if (to_zip) { From 9d2064708a4da41cbae972f63afd103f08abc35a Mon Sep 17 00:00:00 2001 From: hsonne Date: Sat, 23 Sep 2023 22:54:12 +0200 Subject: [PATCH 6/9] Consider renaming of "Pegelnullpunkt_m" to "Pegelnullpunkt_m_NHN" --- vignettes/surface-water.Rmd | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/vignettes/surface-water.Rmd b/vignettes/surface-water.Rmd index 015837fa..7d9ed22a 100644 --- a/vignettes/surface-water.Rmd +++ b/vignettes/surface-water.Rmd @@ -5,8 +5,10 @@ date: "`r Sys.time()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Surface Water} - %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} + %\VignetteEngine{knitr::rmarkdown} +editor_options: + chunk_output_type: console --- ```{r, include = FALSE} @@ -88,20 +90,22 @@ swl_master <- wasserportal::get_wasserportal_masters_data( dplyr::pull(.data$stammdaten_link) ) +column_level_zero <- "Pegelnullpunkt_m_NHN" + swl_data <- sw_data_daily_list$surface_water.water_level %>% dplyr::select(where(~!all(is.na(.x)))) %>% dplyr::left_join( - swl_master[, c("Nummer", "Pegelnullpunkt_m")], - by = c("Messstellennummer" = "Nummer") + kwb.utils::selectColumns(swl_master, c("Nummer", column_level_zero)), + by = c(Messstellennummer = "Nummer") ) %>% dplyr::mutate( - Tagesmittelwert_Pegelstand_mNN = as.numeric(.data$Pegelnullpunkt_m) + + Tagesmittelwert_Pegelstand_mNN = as.numeric(.data[[column_level_zero]]) + .data$Tagesmittelwert / 100 ) %>% ### remove -777 for messstellennummer 5867000 (few values in 2000) resulted by ### step above - dplyr::filter(.data$Tagesmittelwert_Pegelstand_mNN != -777) %>% - dplyr::select(- .data$Pegelnullpunkt_m) + dplyr::filter(.data[["Tagesmittelwert_Pegelstand_mNN"]] != -777) %>% + kwb.utils::removeColumns(column_level_zero) str(swl_data) ``` From 0da9968a5d90eb1accdd667b29cba471f8eb3159 Mon Sep 17 00:00:00 2001 From: hsonne Date: Sat, 23 Sep 2023 23:15:31 +0200 Subject: [PATCH 7/9] Create tests with kwb.test::create_test_files() --- DESCRIPTION | 4 +++- tests/testthat.R | 12 ++++++++++++ .../test-function-add_wasserportal_metadata.R | 16 ++++++++++++++++ tests/testthat/test-function-as_date_de.R | 16 ++++++++++++++++ tests/testthat/test-function-assert_date.R | 16 ++++++++++++++++ tests/testthat/test-function-base_url_download.R | 13 +++++++++++++ .../test-function-clean_timestamp_columns.R | 16 ++++++++++++++++ tests/testthat/test-function-columns_to_labels.R | 16 ++++++++++++++++ tests/testthat/test-function-date_string_de.R | 16 ++++++++++++++++ tests/testthat/test-function-extract_hrefs.R | 16 ++++++++++++++++ .../test-function-get_daily_surfacewater_data.R | 16 ++++++++++++++++ .../test-function-get_groundwater_data.R | 16 ++++++++++++++++ .../test-function-get_groundwater_options.R | 13 +++++++++++++ .../test-function-get_non_external_station_ids.R | 16 ++++++++++++++++ .../test-function-get_overview_options.R | 13 +++++++++++++ .../test-function-get_station_variables.R | 16 ++++++++++++++++ tests/testthat/test-function-get_stations.R | 13 +++++++++++++ .../test-function-get_surfacewater_variables.R | 13 +++++++++++++ ..._url_and_body_for_groundwater_data_download.R | 16 ++++++++++++++++ .../test-function-get_wasserportal_master_data.R | 16 ++++++++++++++++ ...test-function-get_wasserportal_masters_data.R | 16 ++++++++++++++++ .../test-function-get_wasserportal_stations.R | 13 +++++++++++++ ...st-function-get_wasserportal_stations_table.R | 13 +++++++++++++ .../test-function-get_wasserportal_text.R | 16 ++++++++++++++++ .../test-function-get_wasserportal_url.R | 16 ++++++++++++++++ .../test-function-get_wasserportal_variables.R | 13 +++++++++++++ tests/testthat/test-function-is_external_link.R | 16 ++++++++++++++++ .../test-function-list_data_to_csv_or_zip.R | 16 ++++++++++++++++ .../test-function-list_masters_data_to_csv.R | 16 ++++++++++++++++ .../test-function-list_timeseries_data_to_zip.R | 16 ++++++++++++++++ .../test-function-merge_raw_results_daily.R | 16 ++++++++++++++++ .../test-function-merge_raw_results_monthly.R | 16 ++++++++++++++++ .../test-function-merge_raw_results_single.R | 16 ++++++++++++++++ .../testthat/test-function-print_invalid_hrefs.R | 16 ++++++++++++++++ tests/testthat/test-function-read.R | 13 +++++++++++++ tests/testthat/test-function-readPackageFile.R | 16 ++++++++++++++++ tests/testthat/test-function-read_wasserportal.R | 16 ++++++++++++++++ .../test-function-read_wasserportal_raw.R | 16 ++++++++++++++++ .../test-function-read_wasserportal_raw_gw.R | 13 +++++++++++++ .../test-function-remove_remaining_duplicates.R | 16 ++++++++++++++++ .../test-function-remove_timestep_outliers.R | 16 ++++++++++++++++ ...est-function-repair_wasserportal_timestamps.R | 16 ++++++++++++++++ ...est-function-stop_on_external_data_provider.R | 16 ++++++++++++++++ .../testthat/test-function-sw_data_list_to_df.R | 16 ++++++++++++++++ tests/testthat/test-function-to_base_filename.R | 16 ++++++++++++++++ .../test-function-warning_not_implemented.R | 16 ++++++++++++++++ .../test-function-wasserportal_base_url.R | 13 +++++++++++++ tests/testthat/test-function-wp_data_to_list.R | 16 ++++++++++++++++ .../test-function-wp_masters_data_to_list.R | 16 ++++++++++++++++ .../test-function-wp_timeseries_data_to_list.R | 16 ++++++++++++++++ 50 files changed, 750 insertions(+), 1 deletion(-) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-function-add_wasserportal_metadata.R create mode 100644 tests/testthat/test-function-as_date_de.R create mode 100644 tests/testthat/test-function-assert_date.R create mode 100644 tests/testthat/test-function-base_url_download.R create mode 100644 tests/testthat/test-function-clean_timestamp_columns.R create mode 100644 tests/testthat/test-function-columns_to_labels.R create mode 100644 tests/testthat/test-function-date_string_de.R create mode 100644 tests/testthat/test-function-extract_hrefs.R create mode 100644 tests/testthat/test-function-get_daily_surfacewater_data.R create mode 100644 tests/testthat/test-function-get_groundwater_data.R create mode 100644 tests/testthat/test-function-get_groundwater_options.R create mode 100644 tests/testthat/test-function-get_non_external_station_ids.R create mode 100644 tests/testthat/test-function-get_overview_options.R create mode 100644 tests/testthat/test-function-get_station_variables.R create mode 100644 tests/testthat/test-function-get_stations.R create mode 100644 tests/testthat/test-function-get_surfacewater_variables.R create mode 100644 tests/testthat/test-function-get_url_and_body_for_groundwater_data_download.R create mode 100644 tests/testthat/test-function-get_wasserportal_master_data.R create mode 100644 tests/testthat/test-function-get_wasserportal_masters_data.R create mode 100644 tests/testthat/test-function-get_wasserportal_stations.R create mode 100644 tests/testthat/test-function-get_wasserportal_stations_table.R create mode 100644 tests/testthat/test-function-get_wasserportal_text.R create mode 100644 tests/testthat/test-function-get_wasserportal_url.R create mode 100644 tests/testthat/test-function-get_wasserportal_variables.R create mode 100644 tests/testthat/test-function-is_external_link.R create mode 100644 tests/testthat/test-function-list_data_to_csv_or_zip.R create mode 100644 tests/testthat/test-function-list_masters_data_to_csv.R create mode 100644 tests/testthat/test-function-list_timeseries_data_to_zip.R create mode 100644 tests/testthat/test-function-merge_raw_results_daily.R create mode 100644 tests/testthat/test-function-merge_raw_results_monthly.R create mode 100644 tests/testthat/test-function-merge_raw_results_single.R create mode 100644 tests/testthat/test-function-print_invalid_hrefs.R create mode 100644 tests/testthat/test-function-read.R create mode 100644 tests/testthat/test-function-readPackageFile.R create mode 100644 tests/testthat/test-function-read_wasserportal.R create mode 100644 tests/testthat/test-function-read_wasserportal_raw.R create mode 100644 tests/testthat/test-function-read_wasserportal_raw_gw.R create mode 100644 tests/testthat/test-function-remove_remaining_duplicates.R create mode 100644 tests/testthat/test-function-remove_timestep_outliers.R create mode 100644 tests/testthat/test-function-repair_wasserportal_timestamps.R create mode 100644 tests/testthat/test-function-stop_on_external_data_provider.R create mode 100644 tests/testthat/test-function-sw_data_list_to_df.R create mode 100644 tests/testthat/test-function-to_base_filename.R create mode 100644 tests/testthat/test-function-warning_not_implemented.R create mode 100644 tests/testthat/test-function-wasserportal_base_url.R create mode 100644 tests/testthat/test-function-wp_data_to_list.R create mode 100644 tests/testthat/test-function-wp_masters_data_to_list.R create mode 100644 tests/testthat/test-function-wp_timeseries_data_to_list.R diff --git a/DESCRIPTION b/DESCRIPTION index 41cc9f0d..18acf69a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -61,7 +61,8 @@ Suggests: plotly, rmarkdown, sf, - tidyselect + tidyselect, + testthat (>= 3.0.0) Remotes: github::kwb-r/kwb.datetime, github::kwb-r/kwb.pkgbuild, @@ -71,3 +72,4 @@ LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.1 VignetteBuilder: knitr +Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 00000000..5b97ae68 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(wasserportal) + +test_check("wasserportal") diff --git a/tests/testthat/test-function-add_wasserportal_metadata.R b/tests/testthat/test-function-add_wasserportal_metadata.R new file mode 100644 index 00000000..e7528965 --- /dev/null +++ b/tests/testthat/test-function-add_wasserportal_metadata.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("add_wasserportal_metadata() works", { + + expect_error( + wasserportal:::add_wasserportal_metadata() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-as_date_de.R b/tests/testthat/test-function-as_date_de.R new file mode 100644 index 00000000..a79515f6 --- /dev/null +++ b/tests/testthat/test-function-as_date_de.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:44.744923. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("as_date_de() works", { + + expect_error( + wasserportal:::as_date_de() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-assert_date.R b/tests/testthat/test-function-assert_date.R new file mode 100644 index 00000000..36548b3f --- /dev/null +++ b/tests/testthat/test-function-assert_date.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:44.744923. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("assert_date() works", { + + expect_error( + wasserportal:::assert_date() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-base_url_download.R b/tests/testthat/test-function-base_url_download.R new file mode 100644 index 00000000..7d7e457f --- /dev/null +++ b/tests/testthat/test-function-base_url_download.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:46.168353. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("base_url_download() works", { + + wasserportal:::base_url_download() + +}) + diff --git a/tests/testthat/test-function-clean_timestamp_columns.R b/tests/testthat/test-function-clean_timestamp_columns.R new file mode 100644 index 00000000..8fc2e3fc --- /dev/null +++ b/tests/testthat/test-function-clean_timestamp_columns.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("clean_timestamp_columns() works", { + + expect_error( + wasserportal:::clean_timestamp_columns() + # argument "data" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-columns_to_labels.R b/tests/testthat/test-function-columns_to_labels.R new file mode 100644 index 00000000..508f44ac --- /dev/null +++ b/tests/testthat/test-function-columns_to_labels.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:44.744923. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("columns_to_labels() works", { + + expect_error( + wasserportal:::columns_to_labels() + # argument "columns" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-date_string_de.R b/tests/testthat/test-function-date_string_de.R new file mode 100644 index 00000000..0df950c4 --- /dev/null +++ b/tests/testthat/test-function-date_string_de.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:44.744923. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("date_string_de() works", { + + expect_error( + wasserportal:::date_string_de() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-extract_hrefs.R b/tests/testthat/test-function-extract_hrefs.R new file mode 100644 index 00000000..e39b2c20 --- /dev/null +++ b/tests/testthat/test-function-extract_hrefs.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:16.145095. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("extract_hrefs() works", { + + expect_error( + wasserportal:::extract_hrefs() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_daily_surfacewater_data.R b/tests/testthat/test-function-get_daily_surfacewater_data.R new file mode 100644 index 00000000..96675e60 --- /dev/null +++ b/tests/testthat/test-function-get_daily_surfacewater_data.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:31.879282. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_daily_surfacewater_data() works", { + + expect_error( + wasserportal:::get_daily_surfacewater_data() + # argument "stations" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_groundwater_data.R b/tests/testthat/test-function-get_groundwater_data.R new file mode 100644 index 00000000..50ac712b --- /dev/null +++ b/tests/testthat/test-function-get_groundwater_data.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:38.376262. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_groundwater_data() works", { + + expect_error( + wasserportal:::get_groundwater_data() + # argument "stations" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_groundwater_options.R b/tests/testthat/test-function-get_groundwater_options.R new file mode 100644 index 00000000..55622b80 --- /dev/null +++ b/tests/testthat/test-function-get_groundwater_options.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:38.376262. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_groundwater_options() works", { + + wasserportal:::get_groundwater_options() + +}) + diff --git a/tests/testthat/test-function-get_non_external_station_ids.R b/tests/testthat/test-function-get_non_external_station_ids.R new file mode 100644 index 00000000..e7abcac0 --- /dev/null +++ b/tests/testthat/test-function-get_non_external_station_ids.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:31.879282. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_non_external_station_ids() works", { + + expect_error( + wasserportal:::get_non_external_station_ids() + # argument "station_data" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_overview_options.R b/tests/testthat/test-function-get_overview_options.R new file mode 100644 index 00000000..15ea723f --- /dev/null +++ b/tests/testthat/test-function-get_overview_options.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:38.527944. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_overview_options() works", { + + wasserportal:::get_overview_options() + +}) + diff --git a/tests/testthat/test-function-get_station_variables.R b/tests/testthat/test-function-get_station_variables.R new file mode 100644 index 00000000..5a165915 --- /dev/null +++ b/tests/testthat/test-function-get_station_variables.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:41.860028. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_station_variables() works", { + + expect_error( + wasserportal:::get_station_variables() + # argument "station_df" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_stations.R b/tests/testthat/test-function-get_stations.R new file mode 100644 index 00000000..38cca306 --- /dev/null +++ b/tests/testthat/test-function-get_stations.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:01.710311. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_stations() works", { + + wasserportal:::get_stations() + +}) + diff --git a/tests/testthat/test-function-get_surfacewater_variables.R b/tests/testthat/test-function-get_surfacewater_variables.R new file mode 100644 index 00000000..bb9c7492 --- /dev/null +++ b/tests/testthat/test-function-get_surfacewater_variables.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:31.879282. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_surfacewater_variables() works", { + + wasserportal:::get_surfacewater_variables() + +}) + diff --git a/tests/testthat/test-function-get_url_and_body_for_groundwater_data_download.R b/tests/testthat/test-function-get_url_and_body_for_groundwater_data_download.R new file mode 100644 index 00000000..566ef5a1 --- /dev/null +++ b/tests/testthat/test-function-get_url_and_body_for_groundwater_data_download.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:43.430779. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_url_and_body_for_groundwater_data_download() works", { + + expect_error( + wasserportal:::get_url_and_body_for_groundwater_data_download() + # argument "stype" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_master_data.R b/tests/testthat/test-function-get_wasserportal_master_data.R new file mode 100644 index 00000000..a0f46d3f --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_master_data.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:07.960625. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_master_data() works", { + + expect_error( + wasserportal:::get_wasserportal_master_data() + # argument "master_url" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_masters_data.R b/tests/testthat/test-function-get_wasserportal_masters_data.R new file mode 100644 index 00000000..d8e292f5 --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_masters_data.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:07.960625. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_masters_data() works", { + + expect_error( + wasserportal:::get_wasserportal_masters_data() + # argument "master_urls" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_stations.R b/tests/testthat/test-function-get_wasserportal_stations.R new file mode 100644 index 00000000..aed472d3 --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_stations.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:08.05047. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_stations() works", { + + wasserportal:::get_wasserportal_stations() + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_stations_table.R b/tests/testthat/test-function-get_wasserportal_stations_table.R new file mode 100644 index 00000000..3bdfca2f --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_stations_table.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:16.145095. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_stations_table() works", { + + wasserportal:::get_wasserportal_stations_table() + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_text.R b/tests/testthat/test-function-get_wasserportal_text.R new file mode 100644 index 00000000..75d89b56 --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_text.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_text() works", { + + expect_error( + wasserportal:::get_wasserportal_text() + # argument "variable_ids" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_url.R b/tests/testthat/test-function-get_wasserportal_url.R new file mode 100644 index 00000000..32c68346 --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_url.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_url() works", { + + expect_error( + wasserportal:::get_wasserportal_url() + # argument "station" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-get_wasserportal_variables.R b/tests/testthat/test-function-get_wasserportal_variables.R new file mode 100644 index 00000000..9a095519 --- /dev/null +++ b/tests/testthat/test-function-get_wasserportal_variables.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:16.872839. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("get_wasserportal_variables() works", { + + wasserportal:::get_wasserportal_variables() + +}) + diff --git a/tests/testthat/test-function-is_external_link.R b/tests/testthat/test-function-is_external_link.R new file mode 100644 index 00000000..75be19d4 --- /dev/null +++ b/tests/testthat/test-function-is_external_link.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:17.601624. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("is_external_link() works", { + + expect_error( + wasserportal:::is_external_link() + # argument "url" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-list_data_to_csv_or_zip.R b/tests/testthat/test-function-list_data_to_csv_or_zip.R new file mode 100644 index 00000000..dcc75bd0 --- /dev/null +++ b/tests/testthat/test-function-list_data_to_csv_or_zip.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:18.335281. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("list_data_to_csv_or_zip() works", { + + expect_error( + wasserportal:::list_data_to_csv_or_zip() + # argument "data_list" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-list_masters_data_to_csv.R b/tests/testthat/test-function-list_masters_data_to_csv.R new file mode 100644 index 00000000..687fa9ef --- /dev/null +++ b/tests/testthat/test-function-list_masters_data_to_csv.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:18.525365. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("list_masters_data_to_csv() works", { + + expect_error( + wasserportal:::list_masters_data_to_csv() + # argument "masters_data_list" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-list_timeseries_data_to_zip.R b/tests/testthat/test-function-list_timeseries_data_to_zip.R new file mode 100644 index 00000000..6c87918f --- /dev/null +++ b/tests/testthat/test-function-list_timeseries_data_to_zip.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:19.218318. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("list_timeseries_data_to_zip() works", { + + expect_error( + wasserportal:::list_timeseries_data_to_zip() + # argument "timeseries_data_list" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-merge_raw_results_daily.R b/tests/testthat/test-function-merge_raw_results_daily.R new file mode 100644 index 00000000..c06709ee --- /dev/null +++ b/tests/testthat/test-function-merge_raw_results_daily.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:31.576169. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("merge_raw_results_daily() works", { + + expect_error( + wasserportal:::merge_raw_results_daily() + # argument "dfs" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-merge_raw_results_monthly.R b/tests/testthat/test-function-merge_raw_results_monthly.R new file mode 100644 index 00000000..bf99578d --- /dev/null +++ b/tests/testthat/test-function-merge_raw_results_monthly.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:31.576169. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("merge_raw_results_monthly() works", { + + expect_error( + wasserportal:::merge_raw_results_monthly() + # argument "dfs" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-merge_raw_results_single.R b/tests/testthat/test-function-merge_raw_results_single.R new file mode 100644 index 00000000..974fe34d --- /dev/null +++ b/tests/testthat/test-function-merge_raw_results_single.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:31.576169. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("merge_raw_results_single() works", { + + expect_error( + wasserportal:::merge_raw_results_single() + # argument "dfs" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-print_invalid_hrefs.R b/tests/testthat/test-function-print_invalid_hrefs.R new file mode 100644 index 00000000..871918c6 --- /dev/null +++ b/tests/testthat/test-function-print_invalid_hrefs.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:16.145095. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("print_invalid_hrefs() works", { + + expect_error( + wasserportal:::print_invalid_hrefs() + # argument "hrefs" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-read.R b/tests/testthat/test-function-read.R new file mode 100644 index 00000000..c1ed07ba --- /dev/null +++ b/tests/testthat/test-function-read.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:44.744923. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("read() works", { + + wasserportal:::read() + +}) + diff --git a/tests/testthat/test-function-readPackageFile.R b/tests/testthat/test-function-readPackageFile.R new file mode 100644 index 00000000..04019e87 --- /dev/null +++ b/tests/testthat/test-function-readPackageFile.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:44.744923. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("readPackageFile() works", { + + expect_error( + wasserportal:::readPackageFile() + # argument "file" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-read_wasserportal.R b/tests/testthat/test-function-read_wasserportal.R new file mode 100644 index 00000000..746ccbe5 --- /dev/null +++ b/tests/testthat/test-function-read_wasserportal.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:31.576169. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("read_wasserportal() works", { + + expect_error( + wasserportal:::read_wasserportal() + # argument "stations_crosstable" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-read_wasserportal_raw.R b/tests/testthat/test-function-read_wasserportal_raw.R new file mode 100644 index 00000000..878d22f4 --- /dev/null +++ b/tests/testthat/test-function-read_wasserportal_raw.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("read_wasserportal_raw() works", { + + expect_error( + wasserportal:::read_wasserportal_raw() + # argument "station" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-read_wasserportal_raw_gw.R b/tests/testthat/test-function-read_wasserportal_raw_gw.R new file mode 100644 index 00000000..f330722d --- /dev/null +++ b/tests/testthat/test-function-read_wasserportal_raw_gw.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:43.430779. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("read_wasserportal_raw_gw() works", { + + wasserportal:::read_wasserportal_raw_gw() + +}) + diff --git a/tests/testthat/test-function-remove_remaining_duplicates.R b/tests/testthat/test-function-remove_remaining_duplicates.R new file mode 100644 index 00000000..b61c75c8 --- /dev/null +++ b/tests/testthat/test-function-remove_remaining_duplicates.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("remove_remaining_duplicates() works", { + + expect_error( + wasserportal:::remove_remaining_duplicates() + # argument "data" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-remove_timestep_outliers.R b/tests/testthat/test-function-remove_timestep_outliers.R new file mode 100644 index 00000000..eb91fc4f --- /dev/null +++ b/tests/testthat/test-function-remove_timestep_outliers.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("remove_timestep_outliers() works", { + + expect_error( + wasserportal:::remove_timestep_outliers() + # argument "timestamps" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-repair_wasserportal_timestamps.R b/tests/testthat/test-function-repair_wasserportal_timestamps.R new file mode 100644 index 00000000..55e75acc --- /dev/null +++ b/tests/testthat/test-function-repair_wasserportal_timestamps.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:33.492441. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("repair_wasserportal_timestamps() works", { + + expect_error( + wasserportal:::repair_wasserportal_timestamps() + # argument "timestamps" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-stop_on_external_data_provider.R b/tests/testthat/test-function-stop_on_external_data_provider.R new file mode 100644 index 00000000..c8805e65 --- /dev/null +++ b/tests/testthat/test-function-stop_on_external_data_provider.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:07.960625. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("stop_on_external_data_provider() works", { + + expect_error( + wasserportal:::stop_on_external_data_provider() + # argument "url" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-sw_data_list_to_df.R b/tests/testthat/test-function-sw_data_list_to_df.R new file mode 100644 index 00000000..75bcc540 --- /dev/null +++ b/tests/testthat/test-function-sw_data_list_to_df.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:09:31.879282. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("sw_data_list_to_df() works", { + + expect_error( + wasserportal:::sw_data_list_to_df() + # argument "sw_data_list" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-to_base_filename.R b/tests/testthat/test-function-to_base_filename.R new file mode 100644 index 00000000..9af65de9 --- /dev/null +++ b/tests/testthat/test-function-to_base_filename.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:17.601624. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("to_base_filename() works", { + + expect_error( + wasserportal:::to_base_filename() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-warning_not_implemented.R b/tests/testthat/test-function-warning_not_implemented.R new file mode 100644 index 00000000..7e174d33 --- /dev/null +++ b/tests/testthat/test-function-warning_not_implemented.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:31.576169. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("warning_not_implemented() works", { + + expect_error( + wasserportal:::warning_not_implemented() + # argument "x" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-wasserportal_base_url.R b/tests/testthat/test-function-wasserportal_base_url.R new file mode 100644 index 00000000..8ede8100 --- /dev/null +++ b/tests/testthat/test-function-wasserportal_base_url.R @@ -0,0 +1,13 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:17.601624. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("wasserportal_base_url() works", { + + wasserportal:::wasserportal_base_url() + +}) + diff --git a/tests/testthat/test-function-wp_data_to_list.R b/tests/testthat/test-function-wp_data_to_list.R new file mode 100644 index 00000000..240c5425 --- /dev/null +++ b/tests/testthat/test-function-wp_data_to_list.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:46.168353. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("wp_data_to_list() works", { + + expect_error( + wasserportal:::wp_data_to_list() + # argument "target_dir" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-wp_masters_data_to_list.R b/tests/testthat/test-function-wp_masters_data_to_list.R new file mode 100644 index 00000000..03df544a --- /dev/null +++ b/tests/testthat/test-function-wp_masters_data_to_list.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:57.965598. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("wp_masters_data_to_list() works", { + + expect_error( + wasserportal:::wp_masters_data_to_list() + # argument "overview_list_names" is missing, with no default + ) + +}) + diff --git a/tests/testthat/test-function-wp_timeseries_data_to_list.R b/tests/testthat/test-function-wp_timeseries_data_to_list.R new file mode 100644 index 00000000..3d014858 --- /dev/null +++ b/tests/testthat/test-function-wp_timeseries_data_to_list.R @@ -0,0 +1,16 @@ +# +# This test file has been generated by kwb.test::create_test_files() +# launched by user hsonne on 2023-09-23 23:10:58.111249. +# Your are strongly encouraged to modify the dummy functions +# so that real cases are tested. You should then delete this comment. +# + +test_that("wp_timeseries_data_to_list() works", { + + expect_error( + wasserportal:::wp_timeseries_data_to_list() + # argument "overview_list_names" is missing, with no default + ) + +}) + From 079a45329b653b4b0a6f3c9d07cead007127c99b Mon Sep 17 00:00:00 2001 From: hsonne Date: Sun, 24 Sep 2023 00:18:07 +0200 Subject: [PATCH 8/9] Use kwb.utils::select(Elements|Columns)() --- R/get_groundwater_data.R | 6 ++++- .../test-function-get_groundwater_data.R | 25 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/R/get_groundwater_data.R b/R/get_groundwater_data.R index 146d1370..474d6d0e 100644 --- a/R/get_groundwater_data.R +++ b/R/get_groundwater_data.R @@ -35,8 +35,12 @@ get_groundwater_data <- function( "Importing '%s' data (%d/%d)", option_name, i, length(groundwater_options) ), + dbg = debug, expr = { - ids <- stations$overview_list[[option_name]]$Messstellennummer + ids <- stations %>% + kwb.utils::selectElements("overview_list") %>% + kwb.utils::selectElements(option_name) %>% + kwb.utils::selectColumns("Messstellennummer") lapply( X = ids, FUN = function(id) { diff --git a/tests/testthat/test-function-get_groundwater_data.R b/tests/testthat/test-function-get_groundwater_data.R index 50ac712b..659edfea 100644 --- a/tests/testthat/test-function-get_groundwater_data.R +++ b/tests/testthat/test-function-get_groundwater_data.R @@ -7,10 +7,27 @@ test_that("get_groundwater_data() works", { - expect_error( - wasserportal:::get_groundwater_data() - # argument "stations" is missing, with no default + f <- wasserportal:::get_groundwater_data + + expect_error(f(debug = FALSE)) + + stations <- list( + overview_list = list( + groundwater.level = data.frame( + Messstellennummer = 1 + ), + groundwater.quality = data.frame( + Messstellennummer = 1 + ) + ) ) -}) + result <- f(stations, debug = FALSE) + expect_length(result, 2L) + expect_type(result, "list") + + expect_true(all( + sapply(result, kwb.utils::mainClass) == "data.table" + )) +}) From 6da4d3ad9aec3798aad88d2fc29aef2ccc5205a3 Mon Sep 17 00:00:00 2001 From: hsonne Date: Sun, 24 Sep 2023 00:19:08 +0200 Subject: [PATCH 9/9] Implement basic tests where there was no test --- tests/testthat/test-function-base_url_download.R | 5 ++++- .../test-function-get_groundwater_options.R | 6 +++++- tests/testthat/test-function-get_overview_options.R | 9 +++++++-- tests/testthat/test-function-get_stations.R | 7 +++++-- .../test-function-get_surfacewater_variables.R | 7 +++++-- .../test-function-get_wasserportal_stations.R | 6 ++++-- .../test-function-get_wasserportal_stations_table.R | 6 ++++-- .../test-function-get_wasserportal_variables.R | 5 +++-- .../test-function-merge_raw_results_daily.R | 13 ++++++++++--- .../test-function-merge_raw_results_monthly.R | 10 ++++++---- tests/testthat/test-function-read.R | 9 +++++++-- .../test-function-read_wasserportal_raw_gw.R | 12 ++++++++++-- .../testthat/test-function-wasserportal_base_url.R | 7 +++++-- 13 files changed, 75 insertions(+), 27 deletions(-) diff --git a/tests/testthat/test-function-base_url_download.R b/tests/testthat/test-function-base_url_download.R index 7d7e457f..730abc81 100644 --- a/tests/testthat/test-function-base_url_download.R +++ b/tests/testthat/test-function-base_url_download.R @@ -7,7 +7,10 @@ test_that("base_url_download() works", { - wasserportal:::base_url_download() + result <- wasserportal:::base_url_download() + expect_length(result, 1L) + expect_type(result, "character") + expect_true(startsWith(result, "https://")) }) diff --git a/tests/testthat/test-function-get_groundwater_options.R b/tests/testthat/test-function-get_groundwater_options.R index 55622b80..8e164b4b 100644 --- a/tests/testthat/test-function-get_groundwater_options.R +++ b/tests/testthat/test-function-get_groundwater_options.R @@ -7,7 +7,11 @@ test_that("get_groundwater_options() works", { - wasserportal:::get_groundwater_options() + result <- wasserportal:::get_groundwater_options() + expect_identical( + names(result), + c("groundwater.level", "groundwater.quality") + ) }) diff --git a/tests/testthat/test-function-get_overview_options.R b/tests/testthat/test-function-get_overview_options.R index 15ea723f..a5c48a9e 100644 --- a/tests/testthat/test-function-get_overview_options.R +++ b/tests/testthat/test-function-get_overview_options.R @@ -7,7 +7,12 @@ test_that("get_overview_options() works", { - wasserportal:::get_overview_options() + result <- wasserportal:::get_overview_options() -}) + expect_identical( + names(result), + c("surface_water", "groundwater") + ) + expect_true(all(sapply(result, is.list))) +}) diff --git a/tests/testthat/test-function-get_stations.R b/tests/testthat/test-function-get_stations.R index 38cca306..945d4f6a 100644 --- a/tests/testthat/test-function-get_stations.R +++ b/tests/testthat/test-function-get_stations.R @@ -7,7 +7,10 @@ test_that("get_stations() works", { - wasserportal:::get_stations() + expect_output(result <- wasserportal:::get_stations()) + expect_identical( + names(result), + c("overview_list", "overview_df", "crosstable") + ) }) - diff --git a/tests/testthat/test-function-get_surfacewater_variables.R b/tests/testthat/test-function-get_surfacewater_variables.R index bb9c7492..81f73f8c 100644 --- a/tests/testthat/test-function-get_surfacewater_variables.R +++ b/tests/testthat/test-function-get_surfacewater_variables.R @@ -7,7 +7,10 @@ test_that("get_surfacewater_variables() works", { - wasserportal:::get_surfacewater_variables() + result <- wasserportal:::get_surfacewater_variables() -}) + expect_type(result, "character") + + expect_true(all(startsWith(names(result), "surface_water."))) +}) diff --git a/tests/testthat/test-function-get_wasserportal_stations.R b/tests/testthat/test-function-get_wasserportal_stations.R index aed472d3..ddb26156 100644 --- a/tests/testthat/test-function-get_wasserportal_stations.R +++ b/tests/testthat/test-function-get_wasserportal_stations.R @@ -7,7 +7,9 @@ test_that("get_wasserportal_stations() works", { - wasserportal:::get_wasserportal_stations() + result <- wasserportal:::get_wasserportal_stations() -}) + expect_type(result, "list") + expect_true("MS_Sophienwerder" %in% names(result)) +}) diff --git a/tests/testthat/test-function-get_wasserportal_stations_table.R b/tests/testthat/test-function-get_wasserportal_stations_table.R index 3bdfca2f..f633b2e8 100644 --- a/tests/testthat/test-function-get_wasserportal_stations_table.R +++ b/tests/testthat/test-function-get_wasserportal_stations_table.R @@ -7,7 +7,9 @@ test_that("get_wasserportal_stations_table() works", { - wasserportal:::get_wasserportal_stations_table() + result <- wasserportal:::get_wasserportal_stations_table() -}) + expect_true(kwb.utils::mainClass(result) == "tbl_df") + expect_true("Messstellennummer" %in% names(result)) +}) diff --git a/tests/testthat/test-function-get_wasserportal_variables.R b/tests/testthat/test-function-get_wasserportal_variables.R index 9a095519..0c4a8862 100644 --- a/tests/testthat/test-function-get_wasserportal_variables.R +++ b/tests/testthat/test-function-get_wasserportal_variables.R @@ -7,7 +7,8 @@ test_that("get_wasserportal_variables() works", { - wasserportal:::get_wasserportal_variables() + result <- wasserportal:::get_wasserportal_variables() + expect_type(result, "character") + expect_true("Wassertemperatur" %in% names(result)) }) - diff --git a/tests/testthat/test-function-merge_raw_results_daily.R b/tests/testthat/test-function-merge_raw_results_daily.R index c06709ee..da7eb2d3 100644 --- a/tests/testthat/test-function-merge_raw_results_daily.R +++ b/tests/testthat/test-function-merge_raw_results_daily.R @@ -7,10 +7,17 @@ test_that("merge_raw_results_daily() works", { - expect_error( - wasserportal:::merge_raw_results_daily() - # argument "dfs" is missing, with no default + f <- wasserportal:::merge_raw_results_daily + + expect_error(suppressWarnings(f())) + + dfs <- list( + data.frame(a = 1:2), + data.frame(b = 2:3) ) + expect_warning(result <- f(dfs)) + + expect_identical(result, dfs) }) diff --git a/tests/testthat/test-function-merge_raw_results_monthly.R b/tests/testthat/test-function-merge_raw_results_monthly.R index bf99578d..9f262f2d 100644 --- a/tests/testthat/test-function-merge_raw_results_monthly.R +++ b/tests/testthat/test-function-merge_raw_results_monthly.R @@ -7,10 +7,12 @@ test_that("merge_raw_results_monthly() works", { - expect_error( - wasserportal:::merge_raw_results_monthly() - # argument "dfs" is missing, with no default - ) + f <- wasserportal:::merge_raw_results_monthly + + expect_error(suppressWarnings(f())) + + expect_warning(result <- f(123)) + expect_identical(result, 123) }) diff --git a/tests/testthat/test-function-read.R b/tests/testthat/test-function-read.R index c1ed07ba..ba3d3d93 100644 --- a/tests/testthat/test-function-read.R +++ b/tests/testthat/test-function-read.R @@ -7,7 +7,12 @@ test_that("read() works", { - wasserportal:::read() + f <- wasserportal:::read -}) + expect_identical(f(), NULL) + expect_identical( + f(c("a;b", "1;2,3"), header = TRUE), + data.frame(a = 1L, b = 2.3) + ) +}) diff --git a/tests/testthat/test-function-read_wasserportal_raw_gw.R b/tests/testthat/test-function-read_wasserportal_raw_gw.R index f330722d..8666decd 100644 --- a/tests/testthat/test-function-read_wasserportal_raw_gw.R +++ b/tests/testthat/test-function-read_wasserportal_raw_gw.R @@ -7,7 +7,15 @@ test_that("read_wasserportal_raw_gw() works", { - wasserportal:::read_wasserportal_raw_gw() + f <- wasserportal:::read_wasserportal_raw_gw -}) + result <- f() + + expect_identical(kwb.utils::mainClass(result), "tbl_df") + expect_identical( + names(result), + c("Messstellennummer", "Datum", "Parameter", "Einheit", "Messwert") + ) + +}) diff --git a/tests/testthat/test-function-wasserportal_base_url.R b/tests/testthat/test-function-wasserportal_base_url.R index 8ede8100..a0d742f4 100644 --- a/tests/testthat/test-function-wasserportal_base_url.R +++ b/tests/testthat/test-function-wasserportal_base_url.R @@ -7,7 +7,10 @@ test_that("wasserportal_base_url() works", { - wasserportal:::wasserportal_base_url() + result <- wasserportal:::wasserportal_base_url() -}) + expect_type(result, "character") + expect_length(result, 1L) + expect_true(startsWith(result, "https://")) +})