-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug in
qc()
, improve tests, and cleanup .gitlab-ci.yml
- Loading branch information
Showing
5 changed files
with
29 additions
and
18 deletions.
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
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 |
---|---|---|
@@ -1,21 +1,36 @@ | ||
library("testthat") | ||
library("senamhiR") | ||
indat <- senamhiR("000280") | ||
indat <- senamhiR(c("000280", "230715", "47270400")) | ||
|
||
context("Test `qc()`") | ||
|
||
##FIXME, make more interesting tests | ||
## test qc corrections | ||
test_that("qc can fix errors", { | ||
out <- qc(indat) | ||
test_that("qc can fix temperature errors", { | ||
out <- qc(indat[[1]]) | ||
expect_identical(names(out)[15], "Observations") | ||
expect_that(out, is_a("tbl_df")) | ||
expect_output(str(out), "15 variables") | ||
expect_equal(out$`Tmin (C)`[19660], 23.2) | ||
expect_identical(out$Observations[19660], "Tmin dps: 232 -> 23.2 (1.03)") | ||
expect_identical(out$Observations[19558], "Tmin err: 221.2 -> NA") | ||
}) | ||
|
||
test_that("qc can fix CON level errors", { | ||
out <- qc(indat[[2]]) | ||
expect_identical(names(out)[7], "Observations") | ||
expect_that(out, is_a("tbl_df")) | ||
expect_output(str(out), "7 variables") | ||
expect_identical(out$Observations[3262], "Level err: 1.83 -> NA") | ||
}) | ||
|
||
test_that("qc can fix SUT level errors", { | ||
out <- qc(indat[[3]]) | ||
expect_identical(names(out)[11], "Observations") | ||
expect_that(out, is_a("tbl_df")) | ||
expect_output(str(out), "11 variables") | ||
expect_identical(out$Observations[1255], "Level err: -123.51 -> NA") | ||
}) | ||
|
||
## should fail if not enough context | ||
test_that("qc fails if the data set is just one year", { | ||
expect_error(qc(indat[format(indat$Fecha, format = "%Y") == 2013,]), "You've passed a one-year table. We need (many) additional years of data for context.", fixed=TRUE) | ||
expect_error(qc(indat[[1]][format(indat[[1]]$Fecha, format = "%Y") == 2013,]), "You've passed a one-year table. We need (many) additional years of data for context.", fixed=TRUE) | ||
}) |
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