[Stacomir-commits] r595 - in pkg: stacomir stacomirtools/dev stacomirtools/tests/testthat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 10 09:45:39 CET 2021
Author: briand
Date: 2021-11-10 09:45:39 +0100 (Wed, 10 Nov 2021)
New Revision: 595
Modified:
pkg/stacomir/DESCRIPTION
pkg/stacomirtools/dev/03_deploy.R
pkg/stacomirtools/tests/testthat/test-00-connectiondb.R
pkg/stacomirtools/tests/testthat/test-01-connectionODBC.R
pkg/stacomirtools/tests/testthat/test-02-requeteDB.R
pkg/stacomirtools/tests/testthat/test-03-requeteODBC.R
pkg/stacomirtools/tests/testthat/test-04-requeteODBCwhere.R
pkg/stacomirtools/tests/testthat/test-05-requeteODBCwheredate.R
pkg/stacomirtools/tests/testthat/test-06-requeteDBwhere.R
pkg/stacomirtools/tests/testthat/test-07-requeteDBwheredate.R
Log:
Modified: pkg/stacomir/DESCRIPTION
===================================================================
--- pkg/stacomir/DESCRIPTION 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomir/DESCRIPTION 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,6 +1,6 @@
Package: stacomiR
Version: 0.6.0
-Date: 2021-11-07
+Date: 2021-11-09
Title: Fish Migration Monitoring
Authors at R: c(person("Cedric", "Briand", role = c("aut", "cre"), email = "cedric.briand00 at gmail.com"),
person("Marion", "Legrand", role = "aut", email="tableau-salt-loire at logrami.fr"),
Modified: pkg/stacomirtools/dev/03_deploy.R
===================================================================
--- pkg/stacomirtools/dev/03_deploy.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/dev/03_deploy.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -19,7 +19,8 @@
# delete namespace before loading again...
devtools::document()
devtools::build_readme()
-#roxygen2::roxygenise(clean = TRUE) # marche pas si les .Rd ont été écrits à la main il faut les supprimer
+devtools::test()
+lov#roxygen2::roxygenise(clean = TRUE) # marche pas si les .Rd ont été écrits à la main il faut les supprimer
devtools::check()
rhub::check_for_cran()
Modified: pkg/stacomirtools/tests/testthat/test-00-connectiondb.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-00-connectiondb.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-00-connectiondb.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,13 +1,19 @@
context("ConnectionDB")
-
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that ConnectionDB returns a pool object and closes ", {
skip_on_cran()
object<-new("ConnectionDB")
object at dbname <- "bd_contmig_nat"
- object at host <- "localhost"
+ object at host <- host
object at port <- "5432"
- object at user <- "postgres"
- object at password <- "postgres"
+ object at user <- user
+ object at password <- password
object <- connect(object)
expect_true(pool::dbGetInfo(object at connection)$valid)
pool::poolClose(object at connection)
@@ -18,35 +24,48 @@
skip_on_cran()
object <- new("ConnectionDB")
object at dbname <- c("bd_contmig_nat","test")
- object at host <- "localhost"
+ object at host <- host
object at port <- "5432"
- object at user <- "postgres"
- object at password <- "postgres"
+ object at user <- user
+ object at password <- password
expect_error(connect(object))
})
-test_that("Test that RequeteDB returns a pool object", {
+test_that("Test that ConnectionDB returns a pool object", {
skip_on_cran()
- # this requires an odbc link to be setup for test here a database bd_contmig_nat used for stacomir
- # the odbc link is bd_contmig_nat and points to database bd_contmig_nat
object<-new("ConnectionDB")
object at dbname <- "bd_contmig_nat"
- object at host <- "localhost"
+ object at host <- host
object at port <- "5432"
- object at user <- "postgres"
- object at password <- "postgres"
+ object at user <- user
+ object at password <- password
object <- connect(object)
expect_that(object at connection,is_a("Pool"))
pool::poolClose(object at connection)
})
-test_that("Test that RequeteDB works when a base is passed to connect", {
+test_that("Test that ConnectionDB works when a base is passed to connect", {
skip_on_cran()
- # this requires an odbc link to be setup for test here a database bd_contmig_nat used for stacomir
- # the odbc link is bd_contmig_nat and points to database bd_contmig_nat
object<-new("ConnectionDB")
- base <- c("bd_contmig_nat","localhost","5432","postgres","postgres")
+ base <- c("bd_contmig_nat",host,"5432",user,password)
object <- connect(object,base)
expect_that(object at connection,is_a("Pool"))
pool::poolClose(object at connection)
+ })
+
+test_that("Test that ConnectionDB works when using options", {
+ skip_on_cran()
+ o <- options()
+ options(
+ stacomiR.dbname = "bd_contmig_nat",
+ stacomiR.host = host,
+ stacomiR.port = "5432",
+ stacomiR.user = user,
+ stacomiR.password = password
+ )
+ object <-new("ConnectionDB")
+ object <- connect(object)
+ expect_that(object at connection,is_a("Pool"))
+ pool::poolClose(object at connection)
+ options(o)
})
\ No newline at end of file
Modified: pkg/stacomirtools/tests/testthat/test-01-connectionODBC.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-01-connectionODBC.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-01-connectionODBC.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,12 +1,18 @@
context("ConnectionODBC")
-test_that("Test that ConnectionODBC returns the sql string when envir_stacomi and showmerequest ", {
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
+test_that("ConnectionODBC works", {
skip_on_cran()
- envir_stacomi <- new.env()
- assign("showmerequest",1,envir_stacomi)
+ options(stacomiR.printquery=TRUE)
object <- new("ConnectionODBC")
- object at baseODBC <- c("bd_contmig_nat","postgres","postgres")
+ object at baseODBC <- c("bd_contmig_nat", user, password)
object <- connect(object)
expect_that(object at connection,is_a("RODBC"))
odbcClose(object at connection)
Modified: pkg/stacomirtools/tests/testthat/test-02-requeteDB.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-02-requeteDB.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-02-requeteDB.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,13 +1,20 @@
context("RequeteDB")
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that RequeteDB works on a database ", {
skip_on_cran()
object <-new("RequeteDB")
object at sql <- "select * from iav.t_lot_lot limit 10"
object at dbname <- "bd_contmig_nat"
- object at host <- "localhost"
+ object at host <- host
object at port <- "5432"
- object at user <- "postgres"
- object at password <- "postgres"
+ object at user <- user
+ object at password <- password
object <- query(object)
expect_that(object at connection,is_a("Pool"))
expect_gt(nrow(object at query),0)
@@ -17,7 +24,7 @@
skip_on_cran()
object <-new("RequeteDB")
base <-
- c("bd_contmig_nat", "localhost", "5432", "postgres", "postgres")
+ c("bd_contmig_nat", host, "5432", user, password)
object at sql <- "select * from iav.t_lot_lot limit 10"
object <- query(object, base)
expect_that(object at connection,is_a("Pool"))
@@ -29,10 +36,10 @@
o <- options()
options(
stacomiR.dbname = "bd_contmig_nat",
- stacomiR.host ="localhost",
+ stacomiR.host = host,
stacomiR.port = "5432",
- stacomiR.user = "postgres",
- stacomiR.password = "postgres"
+ stacomiR.user = user,
+ stacomiR.password = password
)
object <-new("RequeteDB")
object at sql <- "select * from iav.t_lot_lot limit 10"
@@ -49,7 +56,7 @@
o <- options()
options(
stacomiR.dbname = "bd_contmig_nat",
- stacomiR.host ="localhost",
+ stacomiR.host = host,
stacomiR.port = "5432",
stacomiR.user = "",
stacomiR.password = ""
@@ -63,6 +70,7 @@
test_that("Test that RequeteDB returns the sql string when options(stacomiR.printquery=TRUE) ", {
skip_on_cran()
+ o <- options()
options(
stacomiR.printqueries = TRUE
)
@@ -69,12 +77,12 @@
object <- new("RequeteDB")
object at sql <- "select * from iav.t_lot_lot limit 10"
object at dbname <- "bd_contmig_nat"
- object at host <- "localhost"
+ object at host <- host
object at port <- "5432"
- object at user <- "postgres"
- object at password <- "postgres"
+ object at user <- user
+ object at password <- password
expect_output(object<-query(object))
+ options(o)
-
})
Modified: pkg/stacomirtools/tests/testthat/test-03-requeteODBC.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-03-requeteODBC.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-03-requeteODBC.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,11 +1,17 @@
context("RequeteODBC")
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that RequeteODBC works on a database ", {
skip_on_cran()
# this requires an odbc link to be setup for test here a database bd_contmig_nat used for stacomir
# the odbc link is bd_contmig_nat and points to database bd_contmig_nat
- # userlocal and passwordlocal are generated from Rprofile.site
object <-new("RequeteODBC")
- object at baseODBC=c("bd_contmig_nat","postgres","postgres")
+ object at baseODBC=c("bd_contmig_nat",user,password)
object at sql <- "select * from iav.t_lot_lot limit 10"
object <- connect(object)
expect_that(object at connection,is_a("RODBC"))
@@ -13,14 +19,12 @@
-test_that("Test that RequeteODBC returns the sql string when envir_stacomi and showmerequest ", {
+test_that("Test that RequeteDB returns the sql string when options(stacomiR.printquery=TRUE) ", {
skip_on_cran()
- skip_if_not_installed ("stacomiR")
- envir_stacomi <- new.env(parent=asNamespace("stacomiR"))
- assign("showmerequest",1,envir_stacomi)
+ options(stacomiR.printquery=TRUE)
req<-new("RequeteODBC")
req at sql<-"select * from iav.t_lot_lot limit 10"
- req at baseODBC <- c("bd_contmig_nat","postgres","postgres")
+ req at baseODBC <- c("bd_contmig_nat",user,password)
expect_output(req<- connect(req))
})
Modified: pkg/stacomirtools/tests/testthat/test-04-requeteODBCwhere.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-04-requeteODBCwhere.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-04-requeteODBCwhere.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,4 +1,11 @@
context("RequeteODBCwhere")
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that RequeteODBCwhere returns rows", {
skip_on_cran()
# this requires an odbc link to be setup for test here a database bd_contmig_nat used for stacomir
@@ -9,7 +16,7 @@
object at where <- "WHERE lot_tax_code='2038'"
object at and<-c("AND lot_std_code='CIV'","AND lot_ope_identifiant<1000")
object at order_by<-"ORDER BY lot_identifiant limit 10"
- object at baseODBC=c("bd_contmig_nat","postgres","postgres")
+ object at baseODBC=c("bd_contmig_nat", user, password )
object <- connect(object)
expect_gt(nrow(object at query),0)
})
Modified: pkg/stacomirtools/tests/testthat/test-05-requeteODBCwheredate.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-05-requeteODBCwheredate.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-05-requeteODBCwheredate.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,4 +1,11 @@
context("RequeteODBCwheredate")
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that RequeteODBCwheredate returns rows", {
skip_on_cran()
# this requires an odbc link to be setup for test here a database bd_contmig_nat used for stacomir
@@ -12,7 +19,7 @@
object at select<- "select * from iav.t_operation_ope"
object at where <- "WHERE ope_dic_identifiant=5"
object at order_by<-"limit 10"
- object at baseODBC=c("bd_contmig_nat","postgres","postgres")
+ object at baseODBC=c("bd_contmig_nat",user,password)
object <- connect(object)
expect_gt(nrow(object at query),0)
})
Modified: pkg/stacomirtools/tests/testthat/test-06-requeteDBwhere.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-06-requeteDBwhere.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-06-requeteDBwhere.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,8 +1,15 @@
context("RequeteDBwhere")
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that RequeteDBwhere returns rows", {
skip_on_cran()
object <-new("RequeteDBwhere")
- base=c("bd_contmig_nat","localhost","5432","postgres", "postgres")
+ base=c("bd_contmig_nat",host,"5432",user, password)
object at select<- "select * from iav.t_lot_lot"
object at where <- "WHERE lot_tax_code='2038'"
object at and<-c("AND lot_std_code='CIV'")
Modified: pkg/stacomirtools/tests/testthat/test-07-requeteDBwheredate.R
===================================================================
--- pkg/stacomirtools/tests/testthat/test-07-requeteDBwheredate.R 2021-11-09 12:40:04 UTC (rev 594)
+++ pkg/stacomirtools/tests/testthat/test-07-requeteDBwheredate.R 2021-11-10 08:45:39 UTC (rev 595)
@@ -1,8 +1,15 @@
context("RequeteDBwheredate")
+if (interactive()){
+ if (!exists("user")){
+ host <- readline(prompt="Enter host: ")
+ user <- readline(prompt="Enter user: ")
+ password <- readline(prompt="Enter password: ")
+ }
+}
test_that("Test that RequeteDBwheredate works on a database ", {
skip_on_cran()
object <-new("RequeteDBwheredate")
- base=c("bd_contmig_nat","localhost","5432","postgres", "postgres")
+ base=c("bd_contmig_nat",host,"5432",user, password)
object at datedebut <- strptime("2012-01-01 00:00:00", format="%Y-%m-%d %H:%M:%S")
object at datefin <- strptime("2013-01-01 00:00:00", format="%Y-%m-%d %H:%M:%S")
object at colonnedebut="ope_date_debut"
More information about the Stacomir-commits
mailing list