From 1f8a2a6ae35dd3bf73a24f342b9fb0cc18bdc281 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Wed, 25 Oct 2023 14:08:16 +0100 Subject: [PATCH] temperature summaries test --- tests/test_1_annual.rds | Bin 0 -> 548 bytes tests/test_1_monthly.rds | Bin 0 -> 1441 bytes .../test-total_temperature_summaries.R | 43 +++++++----------- 3 files changed, 16 insertions(+), 27 deletions(-) create mode 100644 tests/test_1_annual.rds create mode 100644 tests/test_1_monthly.rds diff --git a/tests/test_1_annual.rds b/tests/test_1_annual.rds new file mode 100644 index 0000000000000000000000000000000000000000..42543404e2c76f0db9a5690d054ec685ceaeee44 GIT binary patch literal 548 zcmV+<0^9u`iwFP!0000028~p|Z`3dp_T|SN7bq%p=3h9eCjsk~BGfJwQWrMMmpGB7 zoD^oh-yQ4imfi(=-O#H!>a{KK>NP+^6PeQ^noIq++4SyYB%u;ug99?7 z0C__yqFBK(ug_NS!+nYOSdvh#H<2v>0Z^EeDa}Dv2#OA4M!8}si`S&OdB`%(Qv8Tz zb787qB42bM_lU#~X-RoPxRQ;Wke^#il)fDA7WsU}HQ3v-;AY8@CPFAI2;;CrLk(p3 z_5sVNz|#dbq~Zl7LVM3)Xq*$-8cs@LRaiK(gC4xm_Ey_FZ715^n>Nka^FOBj!6{rP z<9k299G{&|w!gpnaQ5-jfAJ4qf4=kM+po#a@0Xij?=v`TQ9K>FPEAps;k~M=zf0h- zvTX#N%CQQod9Vp*lyIzOn$J}Sc?LC{iDF(#tA5X_zcJ08ySr209z5;Pv|qJ#7r;2{ z4?D2^3*V(02Th!<^jdXQc@5$1YZVo>7-)*fcQ-a)4a2Zs&#U&W>atXelG*?SuJA2r z<0w`_;+#o^i`4b8begZ5xdC)k>eBSpG{=dH_w~-DN{Aw(R9p<{dIh9c0jj(;(hEmg m!0^QjM~NuP)iJdSb%Ks+8Pepk*sGO}&i?_{Vh)th1polmAP*)0 literal 0 HcmV?d00001 diff --git a/tests/test_1_monthly.rds b/tests/test_1_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6>b*G3aj!gw(5&PQ5A_s9x8I*m4;cajf49M7;Ljel88VFx989>$T(5enUUpglONI zXrD2br+S(ge%Sh*q@DeNCEL_Tfj(8*5L0>E?^nIZbyVj3n~IPe^CYK6s_My5;xmHS zAC5>zJc7tTjEEUG5-|!f8Zicui6AG?Sj0HQctkd00wO17TrMIHF%glEC_qd?Oh%Xy zg@__VF=9&0I12)=;Z!N23{j4t5#$WEA*LcK5Ys5R!uP%q1*Db$uNtE?((6=G@(Py} z46$AzB(Z)^B)&=~`HpN9Lg*)g5i`)T#+XjP2NFas`q~VTa!Y% vhuyD5cmimz-G(A}&>x_BrE(vq^%39Xt;@UbJN|IXpzi$xaRFm3F%19!)Re7C literal 0 HcmV?d00001 diff --git a/tests/testthat/test-total_temperature_summaries.R b/tests/testthat/test-total_temperature_summaries.R index 7a8fcc1..4ce409e 100644 --- a/tests/testthat/test-total_temperature_summaries.R +++ b/tests/testthat/test-total_temperature_summaries.R @@ -1,27 +1,16 @@ -# library(testthat) -# -# # Test case 1: Test with to = "annual" -# result <- epicsawrap:::total_temperature_summaries( -# country = "zm", -# station_id = "23", -# summaries = c("mean_tmin", "mean_tmax"), -# to = "annual" -# ) -# -# # Test case 2: Test with to = "monthly" -# result_2 <- epicsawrap:::total_temperature_summaries( -# country = "zm", -# station_id = "1", -# summaries = c("mean_tmin", "mean_tmax"), -# to = "monthly" -# ) -# -# # Define test cases -# test_that("total_temperature_summaries returns correct results", { -# # Mock the necessary external functions or datasets if needed -# expect_length(result, 2) -# expect_length(result_2, 2) -# -# expect_no_error(result) -# expect_no_error(result_2) -# }) \ No newline at end of file +library(testthat) +library(rpicsa) + +# Test case 1 +epicsawrap::gcs_auth_file(file = "tests/e-picsa-e630400792e7.json") +test_1_annual <- readRDS("tests/test_1_annual.rds") +test_1_monthly <- readRDS("tests/test_1_monthly.rds") +country <- "zm" +station_id <- "test_1" +result_annual <- epicsawrap::annual_temperature_summaries(country, station_id) +result_monthly <- epicsawrap::monthly_temperature_summaries(country, station_id) + +test_that("Correct summaries are calculated", { + expect_true(identical(result_annual[[2]], test_1_annual)) + expect_true(identical(result_monthly[[2]], test_1_monthly)) +}) \ No newline at end of file