[Stacomir-commits] r387 - in pkg/stacomir: data inst/config inst/tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 8 13:31:11 CEST 2017


Author: briand
Date: 2017-06-08 13:31:10 +0200 (Thu, 08 Jun 2017)
New Revision: 387

Modified:
   pkg/stacomir/data/bilPM.rda
   pkg/stacomir/data/bilan_adm.rda
   pkg/stacomir/inst/config/generate_data.R
   pkg/stacomir/inst/tests/testthat/test-00stacomir.R
   pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
Log:
final changes for Rcheck & tests

Modified: pkg/stacomir/data/bilPM.rda
===================================================================
(Binary files differ)

Modified: pkg/stacomir/data/bilan_adm.rda
===================================================================
(Binary files differ)

Modified: pkg/stacomir/inst/config/generate_data.R
===================================================================
--- pkg/stacomir/inst/config/generate_data.R	2017-06-08 09:22:43 UTC (rev 386)
+++ pkg/stacomir/inst/config/generate_data.R	2017-06-08 11:31:10 UTC (rev 387)
@@ -3,7 +3,7 @@
 # In data :
 #For sets of data, set up a package to use lazy-loading of data. 
 #
-#For objects which are system data, for example lookup tables used in calculations
+#For objects which are system data, for example lookup tables used in bilcalculations
 #within the function, use a file ‘R/sysdata.rda’ in the package sources or create the 
 #objects by R code at package installation time. 
 #
@@ -389,6 +389,7 @@
 # generates dataset for BilanPoidsMoyen : iav
 ##################################
 setwd("C:/workspace/stacomir/pkg/stacomir")
+Sys.setenv(LANG = "EN")
 require(stacomiR)
 stacomi(gr_interface=FALSE,
 		login_window=FALSE,
@@ -451,6 +452,8 @@
 bilan_adm at taxons@data[,"tax_nom_commun"]<-iconv(bilan_adm at taxons@data[,"tax_nom_commun"],from="latin1",to="UTF8")
 bilan_adm at par@data[,"par_nom"]<-iconv(bilan_adm at par@data[,"par_nom"],from="latin1",to="UTF8")
 bilan_adm at stades@data[,"std_libelle"]<-iconv(bilan_adm at stades@data[,"std_libelle"],from="latin1",to="UTF8")
+bilan_adm at data$car_valeur_quantitatif[bilan_adm at data$car_par_code=="C001"]<-
+		bilan_adm at data$car_valeur_quantitatif[bilan_adm at data$car_par_code=="C001"]/10
 bilan_adm<-calcule(bilan_adm)
 devtools::use_data(bilan_adm,internal=FALSE,overwrite=TRUE)
 

Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2017-06-08 09:22:43 UTC (rev 386)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2017-06-08 11:31:10 UTC (rev 387)
@@ -41,6 +41,26 @@
 			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 
+
+#test_that("testconnection to logrami serveur",{
+#			require(stacomiR)
+#			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=TRUE)
+#			baseODBC<-get("baseODBC",envir=envir_stacomi)
+#			baseODBC[1]<- "BD_CONTMIG_SERVEUR"
+#			baseODBC[c(2,3)]<-rep('logrami',2)
+#			assign("baseODBC",baseODBC,envir_stacomi)
+#			sch<-get("sch",envir=envir_stacomi)
+#			assign("sch",paste('logrami',".", sep=""),envir_stacomi)
+#			con=new("ConnectionODBC")		
+#			con at baseODBC=baseODBC
+#			con<-connect(con)
+#			expect_is(connect(con),'ConnectionODBC')
+#			expect_equal(con at etat,"Connection in progress")
+#			odbcCloseAll()			
+#			rm("envir_stacomi",envir =.GlobalEnv)
+#		})
+
+
 test_that("Test that positive count for nrow(ref.tr_taxon_tax)",{
 			require(stacomiR)
 			envir_stacomi <<- new.env(parent = emptyenv())

Modified: pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R	2017-06-08 09:22:43 UTC (rev 386)
+++ pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R	2017-06-08 11:31:10 UTC (rev 387)
@@ -93,7 +93,7 @@
 			assign("baseODBC",baseODBC,envir_stacomi)
 			sch<-get("sch",envir=envir_stacomi) # "iav."
 			assign("sch","iav.",envir_stacomi)
-	# this chunk is not launched from examples but loads the bM_Arzal dataset if connection works	
+			# this chunk is not launched from examples but loads the bM_Arzal dataset if connection works	
 			bM_Arzal=new("BilanMigration")
 			bM_Arzal=choice_c(bM_Arzal,
 					dc=5,
@@ -106,7 +106,7 @@
 			
 			expect_length(bM_Arzal at data,11)
 			rm("envir_stacomi",envir =.GlobalEnv)
-})
+		})
 
 test_that("Test example 02_BilanMigration",
 		{
@@ -171,8 +171,8 @@
 			data("bM_Arzal")
 			bM_Arzal<-calcule(bM_Arzal,silent=TRUE)
 			expect_equal(
-			sum(bM_Arzal at calcdata$dc_5$data$Effectif_total),
-			sum(bM_Arzal at data[bM_Arzal at data$ope_dic_identifiant==5,"value"]))
+					sum(bM_Arzal at calcdata$dc_5$data$Effectif_total),
+					sum(bM_Arzal at data[bM_Arzal at data$ope_dic_identifiant==5,"value"]))
 			write_database(object=bM_Arzal,silent=TRUE)
 			# using setAs to transform the bilanMigration into BilanMigrationInterAnnuelle
 			bili=as(bM_Arzal,"BilanMigrationInterAnnuelle")			
@@ -184,15 +184,15 @@
 					sum(bM_Arzal at calcdata$dc_5$data$Effectif_total),
 					bila at data$effectif,
 					label="The sum of number in the BilanMigration are different to the
-number in the BilanAnnuel class"
-					)
-		
+							number in the BilanAnnuel class"
+			)
+			
 			bili<-connect(bili,check=TRUE,silent=TRUE)
 			expect_equal(
-			sum(bM_Arzal at calcdata$dc_5$data$Effectif_total),	
-			sum(bili at data$bjo_valeur[bili at data$bjo_labelquantite=="Effectif_total"]),			
-			label="The sum of number in the BilanMigration are different to the
-					number in the BilanMigrationInterAnnuelle")
+					sum(bM_Arzal at calcdata$dc_5$data$Effectif_total),	
+					sum(bili at data$bjo_valeur[bili at data$bjo_labelquantite=="Effectif_total"]),			
+					label="The sum of number in the BilanMigration are different to the
+							number in the BilanMigrationInterAnnuelle")
 			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 
@@ -271,4 +271,56 @@
 			plot(bM_Arzal_civ,silent=TRUE,bty="n")
 			summary(bM_Arzal_civ,silent=TRUE)
 			rm("envir_stacomi",envir =.GlobalEnv)
+		})
+# here require setting a connection to logrami server under the name BD_CONTMIG_NAT_SERVEUR
+test_that("test connexion to logrami server",
+		{
+			require(stacomiR)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=TRUE)
+			baseODBC<-get("baseODBC",envir=envir_stacomi)
+			baseODBC[1]<- "BD_CONTMIG_SERVEUR"
+			baseODBC[c(2,3)]<-rep('logrami',2)
+			assign("baseODBC",baseODBC,envir_stacomi)
+			sch<-get("sch",envir=envir_stacomi)
+			assign("sch",paste('logrami',".", sep=""),envir_stacomi)		
+			sqldf.options<-get("sqldf.options",envir=envir_stacomi)
+			getpassword<-function(){  
+				require(tcltk);  
+				wnd<-tktoplevel();tclVar("")->passVar;  
+				#Label  
+				tkgrid(tklabel(wnd,text="Enter password:"));  
+				#Password box  
+				tkgrid(tkentry(wnd,textvariable=passVar,show="*")->passBox);  
+				#Hitting return will also submit password  
+				tkbind(passBox,"<Return>",function() tkdestroy(wnd));  
+				#OK button  
+				tkgrid(tkbutton(wnd,text="OK",command=function() tkdestroy(wnd)));  
+				#Wait for user to click OK  
+				tkwait.window(wnd);  
+				password<-tclvalue(passVar);  
+				return(password);  
+			}  
+			sqldf.options["sqldf.host"]<-getpassword()
+			sqldf.options["sqldf.port"]<-5432
+			assign("sqldf.options",sqldf.options,envir_stacomi)
+			bilanMigration=new('BilanMigration')
+			bilanMigration=choice_c(bilanMigration,
+					dc=23,
+					taxons=c("Petromyzon marinus"),
+					stades=c(5),
+					datedebut="2015-01-01",
+					datefin="2015-12-31")
+			bilanMigration<-charge(bilanMigration, silent=TRUE)
+			bilanMigration=connect(bilanMigration, silent=TRUE)
+			bilanMigration=calcule(bilanMigration, silent=TRUE)
+		
+			bmi<-new("BilanMigrationInterAnnuelle")
+			bmi<-choice_c(bmi,
+					dc=c(101,107),
+					taxons=c("Silurus glanis"),
+					stades=c(5),
+					anneedebut="2014",
+					anneefin="2016",
+					silent=TRUE)
+			bmi<-connect(bmi, silent=FALSE)			
 		})
\ No newline at end of file



More information about the Stacomir-commits mailing list