-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from IDEMSInternational/LC_changes
Adding unit tests
- Loading branch information
Showing
5 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"))) | ||
# }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
# }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
# }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
# }) |