diff --git a/DESCRIPTION b/DESCRIPTION index c3c80c7..f5d165e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,8 @@ Imports: magrittr, purrr, rlang, - rpicsa + rpicsa, + testthat Remotes: IDEMSInternational/epicsadata, IDEMSInternational/rpicsa \ No newline at end of file diff --git a/tests/testthat/test-annual_rainfall_summaries.R b/tests/testthat/test-annual_rainfall_summaries.R new file mode 100644 index 0000000..abbd33f --- /dev/null +++ b/tests/testthat/test-annual_rainfall_summaries.R @@ -0,0 +1,31 @@ +# 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) +# +# 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) +# +# test_that("Correct summaries are calculated", { +# # Test case 2 +# expect_no_error(result) +# # Test case 3 (add more test cases if needed) +# expect_no_error(result_2) +# }) +# +# test_that("Error is thrown if undefined values", { +# # Test case 1: Error is thrown if undefined values +# 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"))) +# +# # 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"))) +# }) diff --git a/tests/testthat/test-crop_success_probabilities.R b/tests/testthat/test-crop_success_probabilities.R new file mode 100644 index 0000000..ee41901 --- /dev/null +++ b/tests/testthat/test-crop_success_probabilities.R @@ -0,0 +1,34 @@ +# library(testthat) +# +# # External functions call +# # Test case 1: Test with all parameter +# result <- epicsawrap::crop_success_probabilities( +# country = "zm", +# station_id = "16", +# planting_dates = c(1, 2, 3), +# water_requirements = c(100, 200, 300), +# planting_length = 10, +# start_before_season = TRUE +# ) +# +# # Test case 2: Test with missing planting_length parameter +# result_2 <- epicsawrap::crop_success_probabilities( +# country = "zm", +# station_id = "16", +# planting_dates = c(1, 2, 3), +# water_requirements = c(100, 200, 300), +# start_before_season = TRUE +# ) +# +# # Test case 2: Test with all missing parameters +# result_3 <- epicsawrap::crop_success_probabilities( +# country = "zm", +# station_id = "16" +# ) +# +# # Define test cases +# test_that("crop_success_probabilities returns correct results", { +# expect_no_error(result) +# expect_no_error(result_2) +# expect_no_error(result_3) +# }) diff --git a/tests/testthat/test-season_start_probabilities.R b/tests/testthat/test-season_start_probabilities.R new file mode 100644 index 0000000..5f22718 --- /dev/null +++ b/tests/testthat/test-season_start_probabilities.R @@ -0,0 +1,20 @@ +# library(testthat) +# +# # External functions call +# # Test case 1: Test with all parameters +# result <- +# season_start_probabilities( +# country = "zm", +# station_id = "16", +# start_dates = c(10, 20, 100) +# ) +# +# # Test case 2: Test with missing parameters +# result_2 <- +# season_start_probabilities(country = "zm", station_id = "16") +# +# # Define test cases +# test_that("season_start_probabilities returns correct results", { +# expect_no_error(result) +# expect_no_error(result_2) +# }) \ No newline at end of file diff --git a/tests/testthat/test-total_temperature_summaries.R b/tests/testthat/test-total_temperature_summaries.R new file mode 100644 index 0000000..1f5ccd3 --- /dev/null +++ b/tests/testthat/test-total_temperature_summaries.R @@ -0,0 +1,27 @@ +# library(testthat) +# +# # Test case 1: Test with to = "annual" +# result <- 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 <- 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