Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes #26

Merged
merged 6 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# development settings
CONFIGURATION_FILE=./app-configuration.json
PRINT_CONFIGURATION=yes
SOURCE_FILE=./data/raw/input3.rds
SOURCE_FILE=./data/raw/input4.rds
OUTPUT_FILE=./data/output/output.rds
ERROR_FILE=./data/output/error.log
APP_ARTIFACTS_DIR=./data/output/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store
data/output/**
!data/output/.keep
*.keep
496 changes: 238 additions & 258 deletions RFunction.R

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
37 changes: 37 additions & 0 deletions data/raw/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Set of input data to test apps.

*Content*
- input1: 1 goat, median fix rate = 30mins, tracking duration 7.5 month, gps, local movement
- input2: 3 storks, median fix rate = 1sec, tracking duration 2 weeks, gps, local movement
- input3: 1 stork, median fix rate = 1h | 1day | 1 week, tracking duration 11.5 years, argos, includes migration
- input4: 3 geese, median fix rate = 1h | 4h, tracking duration 1.5 years, gps, includes migration

*I/O types*
- all data sets are provided as 'move2_loc'
- input1 & input2 are also provided as 'telemetry.list'

*Projection*
- for 'move2_loc', data are provided in "lat/long" (EPSG:4326) and projected to "Mollweide" (ESRI:54009) in order to test your app accordingly for not projected and projected data. If your app does not allow projected data or only can deal with projected data, document and either build a automatic transformation in the app or make it fail with an informative error message. The app "Change projection" can be refered to for the user to change the projection of the data acordingly previous to your app.

- the 'telemetry.list' examples are in a "aeqd" projection with 0,0 in the center of the track, as this is a common projection used within the ctmm library


*File names*
input1_move2loc_LatLon.rds
input1_move2loc_Mollweide.rds

input2_move2loc_LatLon.rds
input2_move2loc_Mollweide.rds

input3_move2loc_LatLon.rds
input3_move2loc_Mollweide.rds

input4_move2loc_LatLon.rds
input4_move2loc_Mollweide.rds


input1_telemetrylist_aeqd.rds
input2_telemetrylist_aeqd.rds



Binary file added data/raw/stork_argos_movebank_output.rds
Binary file not shown.
Binary file added tests/testthat/data/input3.rds
Binary file not shown.
Binary file removed tests/testthat/data/input3_move1.rds
Binary file not shown.
Binary file modified tests/testthat/data/input3_move2.rds
Binary file not shown.
Binary file added tests/testthat/data/input3_move2loc_LatLon.rds
Binary file not shown.
Empty file.
3 changes: 2 additions & 1 deletion tests/testthat/helper.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_data <- function(test_file) {
test_data_root_dir <- test_path("data")
readRDS(file = file.path(test_data_root_dir, test_file))
}
}

7 changes: 5 additions & 2 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
source(file.path("..", "..", "src", "common", "logger.R"))
source(file.path("..", "..", "src", "common", "runtime_configuration.R"))
source(file.path("..", "..", "src", "io", "app_files.R"))
source(file.path("..", "..", "src", "io", "io_handler.R"))
Sys.setenv("LOCAL_APP_FILES_DIR" = "../../data/local_app_files")
Sys.setenv("USER_APP_FILE_HOME_DIR" = "../../data/auxiliary/user-files")

clearRecentOutput()
# the system under test (sut)
source(file.path("..", "..", "./RFunction.R"))
source(file.path("..", "..", "./RFunction.R"))
39 changes: 39 additions & 0 deletions tests/testthat/test_RFunction.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
source(here("tests/testthat/helper.R"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some unit tests to make sure function executes


test_data <- test_data("input3_move2loc_LatLon.rds")


test_that("function executes with user-passed threshold", {
actual <- rFunction(data = test_data, threshold = 6, window = 756)
expected_count <- 3164
expect_equal(nrow(actual), expected_count)
})


test_that("function executes with default threshold", {
actual <- rFunction(data = test_data, window = 756)
expected_count <- 3164
expect_equal(nrow(actual), expected_count)
})


test_that("function returns nothing and errors with bad window", {
actual <- rFunction(data = test_data)
expect_null(actual)
})


test_that("function preserves input track attributes", {
actual <- rFunction(data = test_data, window = 756)
actual_track_data_attributes <- sort(names(mt_track_data(actual)))
expected_track_data_attirbutes <- sort(names(mt_track_data(test_data)))
expect_equal(actual_track_data_attributes, expected_track_data_attirbutes)
})


test_that("function preserves input track id column", {
actual <- rFunction(data = test_data, window = 756)
actual_track_id_column <- attr(actual, "track_id")
expected_track_id_column <- attr(test_data, "track_id")
expect_equal(actual_track_id_column, expected_track_id_column)
})
3 changes: 2 additions & 1 deletion tests/testthat/testthat.R
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
library(testthat)
library(testthat)
library(here)