[Stacomir-commits] r382 - in pkg/stacomir: inst/config inst/examples inst/tests/testthat man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 7 11:54:45 CEST 2017


Author: briand
Date: 2017-06-07 11:54:45 +0200 (Wed, 07 Jun 2017)
New Revision: 382

Modified:
   pkg/stacomir/inst/config/testthat.R
   pkg/stacomir/inst/examples/bilanAnnuels_example.R
   pkg/stacomir/inst/tests/testthat/test-00stacomir.R
   pkg/stacomir/inst/tests/testthat/test-09Bilan_MigrationAnnuelle.R
   pkg/stacomir/man/BilanAnnuels-class.Rd
Log:
change to pass testhat tests

Modified: pkg/stacomir/inst/config/testthat.R
===================================================================
--- pkg/stacomir/inst/config/testthat.R	2017-06-06 20:06:21 UTC (rev 381)
+++ pkg/stacomir/inst/config/testthat.R	2017-06-07 09:54:45 UTC (rev 382)
@@ -1,25 +1,37 @@
+#install.packages("testthat",dependencies=c("Depends", "Imports"))
+#install.packages("relax")
 require(testthat)
+
+
 getUsername <- function(){
 	name <- Sys.info()[["user"]]
 	return(name)
 }
 if(getUsername() == 'cedric.briand')
 {
-	test_dir("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat")
+	test_dir("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat")
 }
 if(getUsername() == 'marion.legrand')
 {
 	test_dir("C:/Users/logrami/workspace/stacomir/pkg/stacomir/inst/tests/testthat")
 }
 
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-00stacomir.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-00zRefclasses.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-04BilanFonctionnementDC.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-06Bilan_MigrationInterAnnuelle.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-07BilanAgedemer.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-08BilanArgentee.R")
-test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-08BilanArgentee.R")
\ No newline at end of file
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-00stacomir.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-00zRefclasses.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R")
+# warning we don't need to be worried about
+#Quoted identifiers should have class SQL, use DBI::SQL() if the caller performs the quoting.
+# this comes from incompatibility between  RSQLite 1.1-1 and sqldf
+# we don't really use RSQLite and this is only a warning not a problem
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R")
+# if errors check existence of dbname test and grants to test on dbname test
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-04BilanFonctionnementDC.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-06Bilan_MigrationInterAnnuelle.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-07BilanAgedemer.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-08BilanArgentee.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-09Bilan_MigrationAnnuelle.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-11BilanMigrationMultConditionEnv.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-10BilanConditionEnv.R")
+test_file("C:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-12BilanMigrationCar.R")
\ No newline at end of file

Modified: pkg/stacomir/inst/examples/bilanAnnuels_example.R
===================================================================
--- pkg/stacomir/inst/examples/bilanAnnuels_example.R	2017-06-06 20:06:21 UTC (rev 381)
+++ pkg/stacomir/inst/examples/bilanAnnuels_example.R	2017-06-07 09:54:45 UTC (rev 382)
@@ -22,7 +22,6 @@
 }
 # the following dataset has been generated by the previous code
 data(bilA)
-(bilA)
 xtbilA<-xtable(bilA,
 		dc_name=c("Passe bassins","Piege anguille RG","Piege anguille RD"),
 		tax_name="Anguille",
@@ -37,7 +36,7 @@
 				bilA at anneefin@annee_selectionnee,".html",sep=""),fsep ="/")
 # here you can add an argument file=path
 print(xtbilA,type="html")
-}
+
 # the following uses the "addtorow" argument which creates nice column headings,
 # format.args creates a thousand separator
 # again this will need to be saved in a file using the file argument
@@ -64,3 +63,4 @@
 		beside=TRUE)
 }
 plot(bilAM)
+}
\ No newline at end of file

Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2017-06-06 20:06:21 UTC (rev 381)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2017-06-07 09:54:45 UTC (rev 382)
@@ -77,31 +77,29 @@
 			require(stacomiR)
 			stacomi(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE)
 			expect_true(exists("envir_stacomi"))
-			dispose(logw)
 			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 
 test_that("Test that gWidget loginwindow is loaded ",{
 			require(stacomiR)
 			stacomi(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE)
-			expect_true(exists("logw"))
-			dispose(logw)
+			expect_true(exists("logw",envir_stacomi))
 			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 
 test_that("Test that gWidget gr_interface is loaded, without database_expected, nor login window",{
 			require(stacomiR)
 			stacomi(gr_interface=TRUE,login_window=FALSE,database_expected=FALSE)
-			expect_true(exists("win"))
-			dispose(win)
+			expect_true(exists("win",envir_stacomi))			
+			dispose(get("win",envir_stacomi))
 			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 
 test_that("gWidget gr_interface is loaded, with pre launch_test, but without login window",{
 			require(stacomiR)
 			stacomi(gr_interface=TRUE,login_window=FALSE,database_expected=TRUE)
-			expect_true(exists("win"))
-			dispose(win)
+			expect_true(exists("win",envir_stacomi))
+			dispose(get("win",envir_stacomi))
 			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 

Modified: pkg/stacomir/inst/tests/testthat/test-09Bilan_MigrationAnnuelle.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-09Bilan_MigrationAnnuelle.R	2017-06-06 20:06:21 UTC (rev 381)
+++ pkg/stacomir/inst/tests/testthat/test-09Bilan_MigrationAnnuelle.R	2017-06-07 09:54:45 UTC (rev 382)
@@ -17,7 +17,7 @@
 					stades=c("AGJ","AGG"),
 					anneedebut="1996",
 					anneefin="2015",
-					silent=FALSE)
+					silent=TRUE)
 			bilA<-connect(bilA,silent=TRUE)	
 			expect_s4_class(bilA,"BilanAnnuels")
 			rm("envir_stacomi",envir =.GlobalEnv)
@@ -40,9 +40,9 @@
 					stades=c("AGJ","AGG"),
 					anneedebut="1996",
 					anneefin="2015",
-					silent=FALSE)			
+					silent=TRUE)			
 			bilA<-connect(bilA,silent=TRUE)			
-			plot(bilA)
+			plot(bilA,silent=TRUE)
 			barplot(bilA)
 			rm("envir_stacomi",envir =.GlobalEnv)			
 		})
@@ -59,5 +59,43 @@
 				
 		})
 
+test_that("Complement to example")
+{
+	data(bilA)
+	path=file.path(path.expand(get("datawd",envir=envir_stacomi)),
+			paste(paste(bilA at dc@dc_selectionne,collapse="+"),"_",
+					paste(bilA at taxons@data$tax_code,collapse="+"),"_",
+					paste(bilA at stades@data$std_code,collapse="+"),"_",
+					bilA at anneedebut@annee_selectionnee,":",
+					bilA at anneefin@annee_selectionnee,".html",sep=""),fsep ="/")
+# here you can add an argument file=path
+	expect_output(print(xtbilA,type="html"))
+	
+# the following uses the "addtorow" argument which creates nice column headings,
+# format.args creates a thousand separator
+# again this will need to be saved in a file using the file argument
+	expect_output(print(xtbilA,
+			add.to.row=get("addtorow",envir_stacomi),
+			include.rownames = TRUE,
+			include.colnames = FALSE,
+			format.args = list(big.mark = " ", decimal.mark = ",")
+	))
+# barplot transforms the data, further arguments can be passed as to barplot
+	barplot(bilA)
+	barplot(bilA,
+			args.legend=list(x="topleft",bty = "n"),
+			col=c("#CA003E","#1A9266","#E10168","#005327","#FF9194"))
+	
+# An example with custom arguments for legend.text (overriding plot defauts)
+	data(bilAM)
+	if (requireNamespace("RColorBrewer", quietly = TRUE)){
+		lesdc<-bilAM at dc@data$dc_code[bilAM at dc@data$dc%in%bilAM at dc@dc_selectionne]
+		barplot(bilAM,
+				legend.text=lesdc,
+				args.legend=list(x="topleft",bty = "n"),
+				col=RColorBrewer::brewer.pal(9,"Spectral"),
+				beside=TRUE)
+	}
+	plot(bilAM)
+}
 
-

Modified: pkg/stacomir/man/BilanAnnuels-class.Rd
===================================================================
--- pkg/stacomir/man/BilanAnnuels-class.Rd	2017-06-06 20:06:21 UTC (rev 381)
+++ pkg/stacomir/man/BilanAnnuels-class.Rd	2017-06-07 09:54:45 UTC (rev 382)
@@ -63,7 +63,7 @@
 				bilA at anneefin@annee_selectionnee,".html",sep=""),fsep ="/")
 # here you can add an argument file=path
 print(xtbilA,type="html")
-}
+
 # the following uses the "addtorow" argument which creates nice column headings,
 # format.args creates a thousand separator
 # again this will need to be saved in a file using the file argument
@@ -91,6 +91,7 @@
 }
 plot(bilAM)
 }
+}
 \author{
 Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 }



More information about the Stacomir-commits mailing list