Skip to content

Commit

Permalink
Merge pull request #40 from PetterHopp/dev
Browse files Browse the repository at this point in the history
NVIdb v0.11.1
  • Loading branch information
PetterHopp authored Feb 5, 2024
2 parents efe8b55 + 2bbda02 commit 0835838
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 41 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: NVIdb
Title: Tools to facilitate the use of NVI's databases
Version: 0.11.0.9000
Date: 2024-##-##
Version: 0.11.1
Date: 2024-02-05
Authors@R:
c(person(given = "Petter",
family = "Hopp",
Expand Down
16 changes: 3 additions & 13 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
NVIdb 0.11.0.9000 - (2024-##-##)
NVIdb 0.11.1 - (2024-02-05)
----------------------------------------

New features:

-
- set_disease_parameters now accepts the arguments purpose, FUN and select_statement.


Bug fixes:

-


Other changes:

-


BREAKING CHANGES:

-
- set_disease_parameters now accepts metodekode with 2 digits.


NVIdb 0.11.0 - (2024-01-24)
Expand Down
20 changes: 10 additions & 10 deletions tests/testthat/test_PJS_code_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -246,52 +246,52 @@ test_that("Backward translation from description to code", {
# })

test_that("errors for add_PJS_code_description", {

linewidth <- options("width")
options(width = 80)

# skip if no connection to 'FAG' have been established
skip_if_not(dir.exists(set_dir_NVI("FAG")))

# Reads translation table for PJS-codes
PJS_codes_2_text <- read_PJS_codes_2_text()
testdata <- as.data.frame(list("hensiktkode" = c("01001", "01002"),

testdata <- as.data.frame(list("hensiktkode" = c("01001", "01002"),
"metodekode" = c("010001", "010002"),
"ansvarlig_seksjon" = c("01", "02")))

expect_error(add_PJS_code_description("testdata",
translation_table = PJS_codes_2_text,
code_colname = c("hensiktkode", "metodekode", "ansvarlig_seksjon"),
PJS_variable_type = c("hensikt", "metode", "seksjon"),
new_column = c("hensikt", "metode", "seksjon")),
regexp = "Variable 'data': Must be of type 'data.frame', not 'character'.",
fixed = TRUE)

expect_error(add_PJS_code_description(testdata,
translation_table = PJS_codes_2_text,
code_colname = c("hensiktkoder"),
PJS_variable_type = c("hensikt"),
new_column = c("hensikt")),
regexp = "but 'hensiktkoder' is not a column in the data.",
fixed = TRUE)

expect_error(add_PJS_code_description(testdata,
translation_table = PJS_codes_2_text,
code_colname = c("hensiktkode"),
PJS_variable_type = c("hensikter"),
new_column = c("hensikt")),
regexp = "Variable 'PJS_variable_type': Must be a subset of",
fixed = TRUE)

expect_error(add_PJS_code_description(testdata,
translation_table = PJS_codes_2_text,
code_colname = c("hensiktkode"),
PJS_variable_type = c("hensikt"),
new_column = c("metodekode")),
regexp = "The column name(s): 'metodekode' already exist in 'testdata`.",
fixed = TRUE)

options(width = unlist(linewidth))
})

Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_Prodtilskudd.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,20 @@ test_that("errors for copy_Prodtilskudd", {
})

test_that("errors for copy_Prodtilskudd with extracted_date", {

linewidth <- options("width")
options(width = 80)

expect_error(copy_Prodtilskudd(from_path = tempdir(), to_path = "./", Pkode_year = "last",
Pkode_month = "10", extracted_date = "2023-03-31"),
regexp = "Contains only missing values. The input 'last' is",
fixed = TRUE)
expect_error(copy_Prodtilskudd(from_path = tempdir(), to_path = "./", Pkode_year = 2020,

expect_error(copy_Prodtilskudd(from_path = tempdir(), to_path = "./", Pkode_year = 2020,
Pkode_month = "both", extracted_date = "2023-03-31"),
regexp = "The inputs 'both' and 'last' are not accepted when",
fixed = TRUE)

options(width = unlist(linewidth))
})

Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test_login.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ test_that("Errors or warnings for login", {
test_that("Errors or warnings for login_EOS", {
linewidth <- options("width")
options(width = 80)

expect_error(login_EOS(dbinterface = "noodbc"),
regexpr = "Variable 'dbinterface': Must be element of set")

options(width = unlist(linewidth))
})

test_that("Errors or warnings for login_PJS", {
linewidth <- options("width")
options(width = 80)

expect_error(login_PJS(dbinterface = "noodbc"),
regexpr = "Variable 'dbinterface': Must be element of set")

options(width = unlist(linewidth))
})
13 changes: 6 additions & 7 deletions tests/testthat/test_set_disease_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test_that("set disease parameters by direct input", {
missing_art = "non_selected_hensikt"),
regexp = "The argument 'missing_art' is deprecated.",
fixed = TRUE)

expect_equal(parameters,
list("purpose" = NULL,
"hensikt2select" = c("0100108018", "0100109003", "0100111003"),
Expand Down Expand Up @@ -252,15 +252,15 @@ test_that("errors for set_disease_parameters", {
art2select = c("05%", NA),
include_missing_art = "yes"),
regexp = "Variable 'include_missing_art': Must be element of set")

expect_error(set_disease_parameters(purpose = NA,
hensikt2delete = "0100108018",
analytt2select = "01220104%",
utbrudd2select = "2",
art2select = c("05%", NA),
include_missing_art = "always"),
regexp = "Variable 'purpose': May not be NA")

expect_error(set_disease_parameters(purpose = 1,
hensikt2delete = "0100108018",
analytt2select = "01220104%",
Expand All @@ -269,7 +269,7 @@ test_that("errors for set_disease_parameters", {
include_missing_art = "always"),
regexp = "Variable 'purpose': Must be of type 'string' (or 'NULL')",
fixed = TRUE)

expect_error(set_disease_parameters(purpose = "ok_storfe_virus",
hensikt2delete = "0100108018",
analytt2select = "01220104%",
Expand All @@ -280,7 +280,7 @@ test_that("errors for set_disease_parameters", {
select_statement = 1),
regexp = "Must be of type 'string', * not 'double'",
fixed = TRUE)

expect_error(set_disease_parameters(purpose = "ok_storfe_virus",
hensikt2delete = "0100108018",
analytt2select = "01220104%",
Expand All @@ -291,7 +291,6 @@ test_that("errors for set_disease_parameters", {
select_statement = NULL),
regexp = "Must be a function (or 'NULL'), not 'character'",
fixed = TRUE)

options(width = unlist(linewidth))
})

Binary file modified vignettes/NVIdb.pdf
Binary file not shown.

0 comments on commit 0835838

Please sign in to comment.