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

options for strict tests; few enhancements #279

Merged
merged 10 commits into from
Mar 18, 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
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Imports:
Suggests:
knitr (>= 1.42),
rmarkdown (>= 2.19),
testthat (>= 3.1.5)
testthat (>= 3.1.5),
withr (>= 2.0.0)
VignetteBuilder:
knitr
RdMacros:
lifecycle
Config/Needs/verdepcheck: mllg/checkmate, r-lib/lifecycle, r-lib/rlang,
yihui/knitr, rstudio/rmarkdown, insightsengineering/teal.code,
r-lib/testthat
Config/Needs/verdepcheck: insightsengineering/teal.code, mllg/checkmate, r-lib/lifecycle, r-lib/rlang,
yihui/knitr, rstudio/rmarkdown, r-lib/testthat, r-lib/withr
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
Expand Down
3 changes: 0 additions & 3 deletions R/join_keys-extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#' @export
#'
#' @examples
#'
#' # Getter for join_keys ---
#'
#' jk["ds1", "ds2"]
Expand Down Expand Up @@ -131,7 +130,6 @@
#'
#' @export
#' @examples
#'
#' # Setting a new primary key ---
#'
#' jk["ds4", "ds4"] <- "pk4"
Expand Down Expand Up @@ -189,7 +187,6 @@
#'
#' @export
#' @examples
#'
#' # Setting via x[[i]] <- value ---
#'
#' jk <- join_keys()
Expand Down
4 changes: 0 additions & 4 deletions R/join_keys-parents.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ parents.join_keys <- function(x) {
#' @describeIn parents Retrieves parents of `join_keys` inside `teal_data` object.
#' @export
#' @examples
#'
#' # Get parents of join_keys inside teal_data object ---
#'
#' td <- teal_data(
Expand All @@ -56,7 +55,6 @@ parents.teal_data <- function(x) {
#' @describeIn parents Assignment of parents of `join_keys` object.
#' @export
#' @examples
#'
#' # Assignment of parents ---
#'
#' jk <- join_keys(
Expand Down Expand Up @@ -109,7 +107,6 @@ parents.teal_data <- function(x) {
#' @describeIn parents Assignment of parents of `join_keys` inside `teal_data` object.
#' @export
#' @examples
#'
#' # Assignment of parents of join_keys inside teal_data object ---
#'
#' parents(td) <- list("ADTTE" = "ADSL") # replace existing
Expand All @@ -128,7 +125,6 @@ parents.teal_data <- function(x) {
#' @export
#'
#' @examples
#'
#' # Get individual parent ---
#'
#' parent(jk, "ds2")
Expand Down
2 changes: 0 additions & 2 deletions R/join_keys.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ join_keys.teal_data <- function(...) {
#' @order 5
#' @export
#' @examples
#'
#' # Assigning keys via join_keys(x)[i, j] <- value ----
#'
#' obj <- join_keys()
Expand All @@ -133,7 +132,6 @@ join_keys.teal_data <- function(...) {
#' @order 5
#' @export
#' @examples
#'
#' # Setter for join_keys within teal_data ----
#'
#' td <- teal_data()
Expand Down
4 changes: 3 additions & 1 deletion R/verify.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
#' e <- 1"
#' )
#' tdata4
#' try(verify(tdata4)) # fails
#' \dontrun{
#' verify(tdata4) # fails
#' }
#'
#' @name verify
#' @rdname verify
Expand Down
4 changes: 0 additions & 4 deletions man/join_keys.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/parents.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/verify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tests/testthat/setup-options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
# it might happen that it is not used right now, but it is left for possible future use
# use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test
opts_partial_match_old <- list(
warnPartialMatchDollar = getOption("warnPartialMatchDollar"),
warnPartialMatchArgs = getOption("warnPartialMatchArgs"),
warnPartialMatchAttr = getOption("warnPartialMatchAttr")
)
opts_partial_match_new <- list(
warnPartialMatchDollar = TRUE,
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE
)

if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) {
withr::local_options(
opts_partial_match_new,
.local_envir = testthat::teardown_env()
)
}
2 changes: 1 addition & 1 deletion tests/testthat/test-get_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ testthat::test_that("ignores occurrence in a function definition in lapply", {
"b <- lapply(a, FUN = function(x) { x <- x + 1 })",
"b <- Filter(function(x) x > 2, b)",
"x <- 1",
"print(x)"
"identity(x)"
)
tdata <- eval_code(teal_data(), code)
testthat::expect_identical(
Expand Down
26 changes: 13 additions & 13 deletions vignettes/join-keys.Rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Join Keys"
author: "NEST CoreDev"
output:
output:
rmarkdown::html_vignette:
toc: true
vignette: >
Expand Down Expand Up @@ -88,19 +88,19 @@ jk
| Output of `print(jk)` | Output annotation |
| ---------------------------------- |:----------------------------------------:|
| `## A join_keys object containing foreign keys between 3 datasets:` | **Title** |
| `## ds1: [col_1]` | **Primary keys**<br />_\<dataset name\>_: [_\<primary_keys\>_] |
| `## <-- ds2: [col_1]` | **Foreign keys**<br /> _(arrow `<--` denotes `ds1` is the parent of `ds2`)_ |
| `## <-- ds3: [col_1]` | |
| `## ds2: [col_1, col_2]` | |
| `## --> ds1: [col_1]` | arrow `-->` denotes `ds2` is a child of `ds1` |
| `## ds1: [col_1]` | **Primary keys**<br />_\<dataset name\>_: [_\<primary_keys\>_] |
| `## <-- ds2: [col_1]` | **Foreign keys**<br /> _(arrow `<--` denotes `ds1` is the parent of `ds2`)_ |
| `## <-- ds3: [col_1]` | |
| `## ds2: [col_1, col_2]` | |
| `## --> ds1: [col_1]` | arrow `-->` denotes `ds2` is a child of `ds1` |
| `## --* (implicit via parent with): ds3` | **Implicit relationship between `ds2` & `ds3`**<br />_(given that they share common keys with same parent)_ |
| `## ds3: [col_1, col_3]` | |
| `## --> ds1: [col_1]` | |
| `## --* (implicit via parent with): ds2` | |
| `## ds4: [no primary keys]` | |
| `## <-> ds5: [col_5]` | **Foreign keys** <br />_(arrow `<->` denotes no parent definition between datasets)_ |
| `## ds5: [no primary keys]` | |
| `## <-> ds4: [col_4] ` | |
| `## ds3: [col_1, col_3]` | |
| `## --> ds1: [col_1]` | |
| `## --* (implicit via parent with): ds2` | |
| `## ds4: [no primary keys]` | |
| `## <-> ds5: [col_5]` | **Foreign keys** <br />_(arrow `<->` denotes no parent definition between datasets)_ |
| `## ds5: [no primary keys]` | |
| `## <-> ds4: [col_4] ` | |

## Accessing and Modifying keys

Expand Down
Loading