Skip to content

Commit

Permalink
annual summary test
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyclements committed Oct 19, 2023
1 parent 171e9f2 commit 6356e54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
Binary file added test_1_annual_summaries.rds
Binary file not shown.
34 changes: 15 additions & 19 deletions tests/testthat/test-annual_rainfall_summaries.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
# library(testthat)
# library(rpicsa)
#
# # Test case 1
# country <- "zm"
# station_id <- "01122"
# summaries <- c("annual_rain")
# result <- epicsawrap::annual_rainfall_summaries(country, station_id, summaries)
#
# definitions <- definitions(country = "zm", station_id = "16",
# summaries = summaries)
# epicsadata::get_daily_data(country = country, station_id = station_id)
#
# country <- "zm"
# station_id_2 <- "16"
# summaries_2 <- c("start_rains", "end_rains", "annual_rain", "seasonal_rain")
# result_2 <- epicsawrap::annual_rainfall_summaries(country, station_id_2, summaries_2)
#
library(testthat)
library(rpicsa)

# Test case 1
epicsawrap::gcs_auth_file(file = "tests/e-picsa-e630400792e7.json")
test_1_results <- readRDS("test_1_annual_summaries.rds")
country <- "zm"
station_id <- "test_1"
result <- epicsawrap::annual_rainfall_summaries(country, station_id)

test_that("Correct summaries are calculated", {
expect_true(identical(result[[2]], test_1_results))
})

# test_that("Correct summaries are calculated", {
# # Test case 2
# expect_no_error(result)
Expand All @@ -28,7 +24,7 @@
# expect_error(epicsawrap::annual_rainfall_summaries(country, station_id, "end_season"))
#
# # Test case 2: Error is thrown if start_ is not calculated but needed
# expect_error(epicsawrap::annual_rainfall_summaries(country, station_id_2, c("end_rains", "seasonal_rain")))
# expect_error(epicsawrap::annual_rainfall_summaries(country, station_id, c("seasonal_rain")))
#
# # Test case 3: Warning if both end are given and seasonal wanted
# expect_warning(epicsawrap::annual_rainfall_summaries(country, station_id_2, c("start_rains", "end_rains", "end_season", "seasonal_rain")))
Expand Down

0 comments on commit 6356e54

Please sign in to comment.