Skip to content

Commit

Permalink
Merge pull request #156 from thekangaroofactory/beta
Browse files Browse the repository at this point in the history
Milestone partial delivery: Beta
  • Loading branch information
thekangaroofactory authored Jan 24, 2024
2 parents 9dd88b1 + e2b4813 commit 1f92bf7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# -- declare colClasses
colClasses <- c(id = "numeric", date = "POSIXct", name = "character", isvalid = "logical")
colClasses_extra_att <- c(id = "numeric", date = "POSIXct", name = "character", isvalid = "logical", extra_att = "integer")

# -- declare default.val
default_val <- c("name" = "test", "isvalid" = TRUE)
Expand All @@ -27,10 +28,17 @@ skip <- c("isvalid")
# -- build data model
dm <- data_model(colClasses = colClasses, default.val = default_val, default.fun = default_fun, filter = filter, skip = skip)
dm_nofilter <- data_model(colClasses = colClasses, default.val = default_val, default.fun = default_fun, filter = NULL, skip = skip)

dm_extra_att <- data_model(colClasses = colClasses_extra_att, default.val = default_val, default.fun = default_fun, filter = filter, skip = skip)

# -- items
items <- data.frame("id" = c(1705158971950, 1705313192780, 1705313216662, 1705399423521),
"date" = c(2024-01-17, 2024-01-15, 2024-01-14, 2024-01-16),
"name" = c("Banana", "Apple", "Lemon", "Pear"),
"isvalid" = c(TRUE, FALSE, TRUE, FALSE))

# -- items with additional attribute
items_extra_att <- data.frame("id" = c(1705158971950, 1705313192780, 1705313216662, 1705399423521),
"date" = c(2024-01-17, 2024-01-15, 2024-01-14, 2024-01-16),
"name" = c("Banana", "Apple", "Lemon", "Pear"),
"isvalid" = c(TRUE, FALSE, TRUE, FALSE),
"extra_att" = c("this", "is", "an", "extra"))
39 changes: 39 additions & 0 deletions tests/testthat/test-dm_check_integrity.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


test_that("dm_check_integrity", {

# -- function call
output <- dm_check_integrity(data.model = dm, items = items, template = NULL)

# -- check
expect_true(output)

})


test_that("dm_check_integrity: extra attribute in items", {

# -- function call
output <- dm_check_integrity(data.model = dm, items = items_extra_att, template = NULL)

# -- checks:
expect_output(str(output), "data.frame")

# -- check: output dim
expect_equal(dim(output), c(5,6))

})


test_that("dm_check_integrity: extra attribute in data model", {

# -- function call
output <- dm_check_integrity(data.model = dm_extra_att, items = items, template = NULL)

# -- checks:
expect_output(str(output), "data.frame")

# -- check: output dim
expect_equal(dim(output), c(4,6))

})
11 changes: 11 additions & 0 deletions tests/testthat/test-dm_colClasses.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


test_that("dm_colClasses", {

# -- function call
x <- dm_colClasses(data.model = dm)

# -- test
expect_mapequal(x, c(id = "numeric", date = "POSIXct", name = "character", isvalid = "logical"))

})

0 comments on commit 1f92bf7

Please sign in to comment.