Skip to content

Commit

Permalink
fix test and redact
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 17, 2023
1 parent 491ad61 commit 53d1df6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
28 changes: 16 additions & 12 deletions R/join_keys.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# Constructors ====

#' Create a `join_keys` out of a list of `join_key_set` objects
#' Manage relationships between datasets using `join_keys`
#'
#' @description `r lifecycle::badge("stable")`
#' @description
#' `join_keys()` facilitates the creation and retrieval of relationships between datasets.
#' `join_keys` class extends a list and contains keys connecting pairs of datasets. Each element
#' of the list contains keys for specific dataset. Each dataset can have a relationship with
#' itself (primary key) and with other datasets.
#'
#' Note that join keys are created symmetrically, that is, if `dat1` and `dat2`
#' have a join key of `col1`, then 2 join keys are created, `dat1 → dat2` and
#' Note that `join_keys` list is symmetrical, that is, when keys are set between `dat1` and `dat2` it
#' is automatically mirrored between `dat2` and `dat1`.
#' `dat2 → dat1`. The only exception is for a primary key.
#'
#' @details
#'
#' - `join_keys()`: When called without arguments it will return an
#' empty constructor.
#' - `join_keys(x)`: When called with a single argument it will return the `join_keys`
#' object contained in `x` (if it contains a `join_keys` object).
#' - `join_keys(...)`: When called with a single or more `join_key_set` parameters it will
#' create a new object.
#' - `[[.join_keys` is the preferred getter for `join_keys` that returns the
#' relationship between pairs of datasets. It returns `NULL` if there is nor
#' - `join_keys()`: Returns an empty `join_keys` object when called without arguments.
#' - `join_keys(x)`: Returns the `join_keys` object contained in `x` (if it contains one).
#' - `join_keys(...)`: Creates a new object with one or more `join_key_set` parameters.
#' - `join_keys[datanames]`: Returns a subset of the `join_keys` object for given datanames,
#' including their symmetric mirror keys.
#' - `join_keys[i, j]`: Returns join keys between datasets `i` and `j`,
#' including implicit keys inferred from their relationship with a parent.
#'
#' relationship.
#'
#' @order 1
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-join_keys.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ testthat::test_that("[[.join_keys doesn't return keys for given a pair without e
testthat::expect_null(my_keys[["b"]][["c"]])
})

testthat::test_that("[[.join_keys infer keys between child by equal (unordered) foreign keys to parent", {
testthat::test_that("[[.join_keys infer keys between children by equal (unordered) foreign keys to parent", {
my_keys <- join_keys(
join_key("a", "a", "aa"),
join_key("b", "b", "bb"),
Expand All @@ -137,14 +137,14 @@ testthat::test_that("[[.join_keys infer keys between child by equal (unordered)
})

testthat::test_that(
"[[.join_keys infer keys between child by shared foreign keys to parent (key names are unique to datasets)",
"[[.join_keys infer keys between children by foreign keys to common parent. ",
{
my_keys <- join_keys(
join_key("a", "a", "aa"),
join_key("b", "b", "bb"),
join_key("c", "c", "cc"),
join_key("b", "a", c(aa = "bb")),
join_key("c", "a", c(aa = "cc"))
join_key("b", "a", c(bb = "aa")),
join_key("c", "a", c(cc = "aa"))
)
parents(my_keys) <- list("b" = "a", "c" = "a")
testthat::expect_identical(my_keys["b", "c"], c(bb = "cc"))
Expand Down Expand Up @@ -205,7 +205,7 @@ testthat::test_that("[.join_keys returns join_keys object for given dataset incl
testthat::expect_equal(my_keys["d2"], expected)
})

testthat::test_that("[.join_keys returns join_keys object for given dataset and doesn't include its childs", {
testthat::test_that("[.join_keys returns join_keys object for given dataset and doesn't include its children", {
my_keys <- join_keys(
join_key("d1", "d1", "a"),
join_key("d2", "d2", "b"),
Expand Down

0 comments on commit 53d1df6

Please sign in to comment.