From 6356e5413b28f4e40f9d3d6ef11951aef09ee4cd Mon Sep 17 00:00:00 2001 From: lilyclements Date: Thu, 19 Oct 2023 17:35:37 +0100 Subject: [PATCH] annual summary test --- test_1_annual_summaries.rds | Bin 0 -> 435 bytes .../testthat/test-annual_rainfall_summaries.R | 34 ++++++++---------- 2 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 test_1_annual_summaries.rds diff --git a/test_1_annual_summaries.rds b/test_1_annual_summaries.rds new file mode 100644 index 0000000000000000000000000000000000000000..42c8111351c4713e4dc5147abf7513fd43fbe600 GIT binary patch literal 435 zcmV;k0ZjfMiwFP!0000029;91N&`U<-drx8x%?;y!B(&iCKxqEAR^e-T#0T)Nu=Y{3^997hQcFR|IlH&3m(4XUe3_YVzTKOd%%P1C$|5rZzd3Nx z!d|CVZ`2`Nfrw{I07zNafE&Oq;0|yP8ks|xd6)~)t+QVJu2jEQsWiC7a;`Le&ZT9#C=ed2*6Q_NA8ONg|VO0wkNSrl55l{eBwA>4~ z(trPJ9eqF{>tNpiuYf3#o1`GF?^D({x)OD%_?PeQ3tp?ClBmJba-BqORUaG0L!!oJ zOVXSW97w+yGRy`(b+}M+1x)D}drp7{R85*DqXJwCm|#LlPgfvnpmRfW{2IkdQP=u~m!5FJvRxxRKJhB^!^IM?E9tIrSYb zZ`GQcTRO3=6FWN5)QHB0w!3Bd{Z?|_|50(OJnIgI(p>~s{rOXUfPsHjRY@^8zCKYD deaAv0(u%cR%y6|A@Ew8YegJWGa77>l007xP%TxdW literal 0 HcmV?d00001 diff --git a/tests/testthat/test-annual_rainfall_summaries.R b/tests/testthat/test-annual_rainfall_summaries.R index 3402efb..237e8d8 100644 --- a/tests/testthat/test-annual_rainfall_summaries.R +++ b/tests/testthat/test-annual_rainfall_summaries.R @@ -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) @@ -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")))