Skip to content

Commit

Permalink
Merge pull request #40 from KWB-R/dev
Browse files Browse the repository at this point in the history
New release to fix bug due to changed column name
  • Loading branch information
hsonne authored Sep 24, 2023
2 parents 7ef43fe + 1f0f0fc commit 867b6a9
Show file tree
Hide file tree
Showing 55 changed files with 847 additions and 24 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -71,3 +72,4 @@ LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
VignetteBuilder: knitr
Config/testthat/edition: 3
6 changes: 5 additions & 1 deletion R/get_groundwater_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/list_data_to_csv_or_zip.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -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")
16 changes: 16 additions & 0 deletions tests/testthat/test-function-add_wasserportal_metadata.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-as_date_de.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-assert_date.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-base_url_download.R
Original file line number Diff line number Diff line change
@@ -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("base_url_download() works", {

result <- wasserportal:::base_url_download()

expect_length(result, 1L)
expect_type(result, "character")
expect_true(startsWith(result, "https://"))
})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-clean_timestamp_columns.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-columns_to_labels.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-date_string_de.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-extract_hrefs.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_daily_surfacewater_data.R
Original file line number Diff line number Diff line change
@@ -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
)

})

33 changes: 33 additions & 0 deletions tests/testthat/test-function-get_groundwater_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# 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", {

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"
))
})
17 changes: 17 additions & 0 deletions tests/testthat/test-function-get_groundwater_options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# 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", {

result <- wasserportal:::get_groundwater_options()

expect_identical(
names(result),
c("groundwater.level", "groundwater.quality")
)
})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_non_external_station_ids.R
Original file line number Diff line number Diff line change
@@ -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
)

})

18 changes: 18 additions & 0 deletions tests/testthat/test-function-get_overview_options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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", {

result <- wasserportal:::get_overview_options()

expect_identical(
names(result),
c("surface_water", "groundwater")
)

expect_true(all(sapply(result, is.list)))
})
16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_station_variables.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_stations.R
Original file line number Diff line number Diff line change
@@ -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: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", {

expect_output(result <- wasserportal:::get_stations())

expect_identical(
names(result),
c("overview_list", "overview_df", "crosstable")
)
})
16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_surfacewater_variables.R
Original file line number Diff line number Diff line change
@@ -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_surfacewater_variables() works", {

result <- wasserportal:::get_surfacewater_variables()

expect_type(result, "character")

expect_true(all(startsWith(names(result), "surface_water.")))

})
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_wasserportal_master_data.R
Original file line number Diff line number Diff line change
@@ -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
)

})

16 changes: 16 additions & 0 deletions tests/testthat/test-function-get_wasserportal_masters_data.R
Original file line number Diff line number Diff line change
@@ -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
)

})

Loading

0 comments on commit 867b6a9

Please sign in to comment.