[Stacomir-commits] r203 - in pkg/stacomir: R inst/config inst/tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 9 19:53:26 CEST 2016


Author: briand
Date: 2016-09-09 19:53:25 +0200 (Fri, 09 Sep 2016)
New Revision: 203

Added:
   pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R
Removed:
   pkg/stacomir/inst/config/testfile.R
Modified:
   pkg/stacomir/R/BilanEspeces.r
   pkg/stacomir/R/BilanFonctionnementDC.r
   pkg/stacomir/R/BilanFonctionnementDF.r
   pkg/stacomir/R/BilanMigration.r
   pkg/stacomir/R/BilanMigrationConditionEnv.r
   pkg/stacomir/R/BilanMigrationInterAnnuelle.r
   pkg/stacomir/R/BilanMigrationMult.r
   pkg/stacomir/R/BilanMigrationPar.r
   pkg/stacomir/R/Bilan_stades_pigm.r
   pkg/stacomir/R/RefHorodate.r
   pkg/stacomir/R/Refperiode.r
   pkg/stacomir/R/create_generic.r
   pkg/stacomir/R/fn_EcritBilanJournalier.r
   pkg/stacomir/R/fn_EcritBilanMensuel.r
   pkg/stacomir/R/fn_table_per_dis.r
   pkg/stacomir/R/stacomi.r
   pkg/stacomir/R/utilitaires.r
   pkg/stacomir/inst/tests/testthat/test-00stacomir.R
Log:


Modified: pkg/stacomir/R/BilanEspeces.r
===================================================================
--- pkg/stacomir/R/BilanEspeces.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanEspeces.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -142,9 +142,9 @@
 
 #' handler for pie chart
 #' draws a pie chart of species or a pie chart per period
-#' @note no need to re-run calcul if another list has been loaded, negative numbers are converted to positive
-#' @param h handler
-#' @param ... other parameters passed to the function
+#' @note no need to re-run calculation if another list has been loaded, negative numbers are converted to positive
+#' @param h Handler
+#' @param ... Other parameters passed to the function
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
 

Modified: pkg/stacomir/R/BilanFonctionnementDC.r
===================================================================
--- pkg/stacomir/R/BilanFonctionnementDC.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanFonctionnementDC.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -294,7 +294,8 @@
 
 
 #' FuntableDC create a table output for BilanFonctionnementDC class
-#' @param h a handler
+#' @param h Handler
+#' @param ... Additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 funtableDC = function(h,...) {
 	fonctionnementDC=charge(fonctionnementDC)

Modified: pkg/stacomir/R/BilanFonctionnementDF.r
===================================================================
--- pkg/stacomir/R/BilanFonctionnementDF.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanFonctionnementDF.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -145,7 +145,8 @@
 #' funbarchartDF creates a barchart for BilanFonctionnementDF class
 #' 
 #' @note The program cuts periods which overlap between two month
-#' @param h a handler  
+#' @param h handler
+#' @param ... additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
 funbarchartDF = function(h,...) {
@@ -242,7 +243,8 @@
 }   
 
 #' FunboxDF draws rectangles to describe the DF work for BilanFonctionnementDF class
-#' @param h a handler
+#' @param h handler
+#' @param ... additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
 funboxDF = function(h,...) {
@@ -365,7 +367,8 @@
 	}
 }   
 #' FuntableDF create a table output for BilanFonctionnementDF class
-#' @param h a handler
+#' @param h handler
+#' @param ... additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
 funtableDF = function(h,...) {

Modified: pkg/stacomir/R/BilanMigration.r
===================================================================
--- pkg/stacomir/R/BilanMigration.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanMigration.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -270,6 +270,7 @@
 #' @param y From the formals but missing
 #' @param plot.type One of "standard","step". Defaut to \code{standard} the standard BilanMigration with dc and operation displayed, can also be \code{step} or 
 #' \code{multiple} 
+#' @param silent Stops displaying the messages.
 #' @param ... Additional arguments, see \code{plot}, \code{plot.default} and \code{par}
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export

Modified: pkg/stacomir/R/BilanMigrationConditionEnv.r
===================================================================
--- pkg/stacomir/R/BilanMigrationConditionEnv.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanMigrationConditionEnv.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -108,19 +108,11 @@
 			enabled(toolbarlist[["Graph"]])<-TRUE
 		})
 
-#######################################################################
-# handler du calcul BilanMigrationstat : traitements et sauvegardes
-# appelle les fonctions funstat et funtable pour faire le bilan des migrations
-# dans des fichiers csv
-#######################################################################
-hbilanMigrationstat = function(h,...) {
-}
 
-# graphiques (a affiner pb si autre chose que journalier)
-#######################################################################
-# handler du calcul hBilanMigrationgraph
-# appelle les fonctions fungraph pour faire le bilan des migrations
-#######################################################################
+
+#' plot combining one ore several qualitative parameters with the migration trend
+#'  @param h A handler
+#'  @param ... Additional parameters
 hbilanMigrationConditionEnvgraph = function(h,...) {   
 	
 	if (exists("bilanMigrationConditionEnv",envir_stacomi)) {

Modified: pkg/stacomir/R/BilanMigrationInterAnnuelle.r
===================================================================
--- pkg/stacomir/R/BilanMigrationInterAnnuelle.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanMigrationInterAnnuelle.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -161,8 +161,9 @@
 			return(object)
 		}
 )
-# graphique de toutes les migrations interannuelles les unes sur les autres    
-# object = bilanMigrationInterAnnuelle = object
+#' Plot of all interannual from top to bottom
+#' @param h handler
+#' @param ... additional parameters
 hgraphBilanMigrationInterAnnuelle = function(h,...)
 {
 	bilanMigrationInterAnnuelle = charge(bilanMigrationInterAnnuelle)
@@ -196,7 +197,9 @@
 	}
 }
 
-# graphe affichant les migrations journalieres
+#'Plot of daily migrations
+#' @param h handler
+#' @param ... additional parameters
 hgraphBilanMigrationInterAnnuelle2 = function(h,...)
 {
 	bilanMigrationInterAnnuelle = charge(bilanMigrationInterAnnuelle)
@@ -244,20 +247,11 @@
 	} # end if
 }  # end function 
 
-##########################################################################
-#'   @title statistics per time period
-#'   function called for bilamMigrationInterannelle objects
-#'   renames columnns replaces nulls,  
-#'   and calculates reports with time period larger than day
-#'   @param timesplit "week"  "2 week" "month" as provided to seq.POSIXT
-#'   @return dat  a data frame with max mean min per time period
-#####################################################################
 
 
 
 
 
-
 #' statistics per time period
 #' 
 #' function called for bilamMigrationInterannelle objects renames columns
@@ -265,7 +259,7 @@
 #' 
 #' 
 #' @param dat a data frame
-#' @param timesplit "week" "2 week" "month" as provided to seq.POSIXT
+#' @param timesplit "week" "2 week" "month" as provided to seq.POSIXT, default NULL
 #' @return a data frame with mean, max, and min calculated for each timesplit
 #' @seealso \code{\linkS4class{Bilan_poids_moyen}}
 fundat=function(dat,timesplit=NULL)
@@ -336,9 +330,11 @@
 		funout(get("msg",envir_stacomi)$BilanMigrationInterannuelle.5,arret=TRUE)
 	}    # end else
 }
-########################################
-# fonction de creation des bilans cumules
-############################################
+
+#' Step plot with different years displayed on the same graph. One year
+#' can be highlighted against the others
+#' @param h handler
+#' @param ... additional parameters
 hgraphBilanMigrationInterAnnuelle3 = function(h,...)
 { 
 	bilanMigrationInterAnnuelle = charge(bilanMigrationInterAnnuelle)	
@@ -385,10 +381,11 @@
 
 
 
-########################################
-# Bilan migration comparant la migration hebdomadaire et la migration
-# interannuelle hebdomadaire. fonctionne pour mensuelle et quinzaine et hebdomadaire
-############################################
+#' Plot comparing the migration  to the migration  
+#' computed for all years available in the daily migration table.
+#' This function plots comparisions for periods of 1 week, 2 weeks, month
+#'  @param h A handler
+#'  @param ... Additional parameters
 hgraphBilanMigrationInterAnnuelle4 = function(h,...)
 {
 	timesplit=h$action    # timesplit="quinzaine" timesplit="semaine" timesplit="mois"
@@ -459,10 +456,11 @@
 }  # end function 
 
 
-########################################
-# Fonction similaire e la precedente mais pointrange et geom_bar
-# interannuelle hebdomadaire. fonctionne pour mensuelle et quizaine et hebdomadaire
-############################################
+
+#' Function displaying comparaison similar to \link{hgraphBilanMigrationInterAnnuelle4} but using pointrange and geom_bar
+#' This function plots comparisions for periods of 1 week, 2 weeks, month
+#'  @param h A handler
+#'  @param ... Additional parameters
 hgraphBilanMigrationInterAnnuelle5 = function(h,...)
 {
 	timesplit=h$action    # timesplit="quinzaine" # timesplit="mois"
@@ -523,8 +521,11 @@
 	} # end if
 }  # end function 
 
-# graphique des cumuls interannuels pour distinguer des tendances saisonnieres, les donnees sont calculees par 
-# quinzaine puis centrees reduites
+
+#' This function creates a cumulated area plot to highlight seasonal trends in migration. Data are calculated by
+#' 2 weeks period then centered and reduced
+#'  @param h A handler
+#'  @param ... Additional parameters
 hgraphBilanMigrationInterAnnuelle7 = function(h,...)
 {
 	bilanMigrationInterAnnuelle = charge(bilanMigrationInterAnnuelle)
@@ -577,9 +578,9 @@
 		funout(get("msg",envir_stacomi)$BilanMigrationInterannuelle.5)
 	}
 }
-########################################
-# ecriture de fichiers dans le datawd
-############################################
+#'Writing of results in datawd
+#'  @param h A handler
+#'  @param ... Additional parameters
 htableBilanMigrationInterAnnuelle = function(h,...)
 {
 	# chargement des donnees

Modified: pkg/stacomir/R/BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMult.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanMigrationMult.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -311,6 +311,7 @@
 #' @param y From the formals but missing
 #' @param plot.type One of "standard","step","multiple". Defaut to \code{standard} the standard BilanMigration with dc and operation displayed, can also be \code{step} or 
 #' \code{multiple} 
+#' @param silent Stops most messages from being displayed
 #' @param ... Additional arguments, see \code{plot}, \code{plot.default} and \code{par}
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
@@ -819,7 +820,7 @@
 #'  typically video recording whose period are instant events.
 #' @param time.sequence the time sequence to be filled in with new data
 #' @param datasub the initial dataset
-#' #' @param negative "boolean", default FALSE, TRUE indicates a separate sum for negative and positive migrations
+#' @param negative "boolean", default FALSE, TRUE indicates a separate sum for negative and positive migrations
 #' @return A data.frame with number summed over over the time.sequence. 
 #' The function returns the same output than \link{fun_bilanMigrationMult_Overlaps}
 #' but is intended to work faster

Modified: pkg/stacomir/R/BilanMigrationPar.r
===================================================================
--- pkg/stacomir/R/BilanMigrationPar.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/BilanMigrationPar.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -71,7 +71,7 @@
 
 #' handler for bilanmigrationpar
 #' @param h handler
-#' @param ... additional parameters
+#' @param ... Additional parameters
 hbilanMigrationParcalc=function(h,...){
 	calcule(h$action)
 }
@@ -161,7 +161,7 @@
 #' le handler appelle la methode generique graphe sur l'object plot.type=1
 #' 
 #' @param h handler
-#' @param ... additional parameters
+#' @param ... Additional parameters
 hbilanMigrationPargraph = function(h,...) {
 	if (exists("bilanMigrationPar",envir_stacomi)) {
 		bilanMigrationPar<-get("bilanMigrationPar",envir_stacomi)
@@ -173,7 +173,7 @@
 #' le handler appelle la methode generique graphe sur l'object plot.type=2
 #' 
 #' @param h handler
-#' @param ... additional parameters
+#' @param ... Additional parameters
 hbilanMigrationPargraph2=function(h,...){
 	if (exists("bilanMigrationPar",envir_stacomi)) {
 		bilanMigrationPar<-get("bilanMigrationPar",envir_stacomi)
@@ -186,8 +186,8 @@
 #' 
 #' 
 #' @param h handler
-#' @param ... additional parameters
-hbilanMigrationParstat=function(h,...){
+#' @param ... Additional parameters
+hbilanMigrationParstat=function(h){
 	if (exists("bilanMigrationPar",envir_stacomi)) {
 		bilanMigrationPar<-get("bilanMigrationPar",envir_stacomi)
 		plot(bilanMigrationPar,plot.type="summary")
@@ -200,7 +200,9 @@
 #' 
 #' 
 #' @param x An object of class BilanMigrationPar
-#' @param plot.type One of "barplot", "xyplot", "summary table"
+#' @param y not used there
+#' @param plot.type One of "barplot", "xyplot", "summary table
+#' @param ... Additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 setMethod("plot",signature=signature(x="BilanMigrationPar",y="ANY"),definition=function(x,y,plot.type="barplot",...){ 
 			###########################

Modified: pkg/stacomir/R/Bilan_stades_pigm.r
===================================================================
--- pkg/stacomir/R/Bilan_stades_pigm.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/Bilan_stades_pigm.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -169,7 +169,7 @@
 #' as it it convenient to use elsewhere
 #' @usage fntablestade(stades,choicepere="lotpere")
 #' @param stades a data frame containing stage values
-#' @param choicelotpere either "date" or "lot_pere" the first will group pigment stage by date, 
+#' @param choicepere either "date" or "lot_pere" the first will group pigment stage by date, 
 #' the second will allow to keep separate lines when several samples have been collected a given day   
 #' @return a list with tablestades atable with numbers per stage for a given date or lotpere (sample), and date                                                                                                                
 #' @author Cedric Briand \\email{cedric.briand"at"eptb-vilaine.fr}                                                                                                                           
@@ -491,8 +491,7 @@
 #' 
 #' 
 #' @param h A handler
-#' @param additional arguments
-#' @param list() additional arguments
+#' @param ... additional arguments
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 funcalcbilan_stades_pigm<-function(h,...){
 	bilan_stades_pigm<-charge(bilan_stades_pigm)
@@ -516,6 +515,8 @@
 }
 
 #' handler function for fungraphstades
+#' @param h handler
+#' @param ... additional parameters
 hfungraphstades=function(h,...){
 	bilan_stades_pigm<-get("bilan_stades_pigm",envir_stacomi)
 	fungraphstades(
@@ -782,6 +783,8 @@
 
 
 #' gglot function to draw graps of pigment stages
+#' @param h handler
+#' @param ... additional parameters
 fungraphgg=function(h,...){
 	g<-ggplot(bilan_stades_pigm at data) # recupere le data.frame vue_ope_lot qui a ete ecrit apres avoir
 	g<-g+geom_bar(aes(x="",y=lot_effectif,fill=val_libelle,width=1),stat='identity')+  # cette ecriture de geom_bar demande de bien mettre stat='identity', on peut alors passer e geom_bar un x et un y...

Modified: pkg/stacomir/R/RefHorodate.r
===================================================================
--- pkg/stacomir/R/RefHorodate.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/RefHorodate.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -46,6 +46,8 @@
 
 
 #' Method to set the Horodate
+#' @param object An object of class \link{RefHorodate-class}
+#' @param string A string representing an horodate in the format "\%Y-\%m-\%d \%H:\%M:\%S"
 #' @return An Object of class "RefHorodate" 
 #' @author cedric.briand
 #' @docType methods
@@ -89,7 +91,7 @@
 				}
 				object at horodate<-shiftyear(object at horodate,decal)
 			}
-			winhor=gframe(label,container=group,horizontal=!affichecal)
+			winhor=gframe(label,container=group,horizontal=FALSE)
 			pg<-ggroup(horizontal=FALSE,container=winhor)
 			horodate<-gedit(getRefHorodate(object),container=pg,handler=hwinhor,width=20)
 			horodate2=as.character(strftime(object at horodate,"%Y-%m-%d"))

Modified: pkg/stacomir/R/Refperiode.r
===================================================================
--- pkg/stacomir/R/Refperiode.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/Refperiode.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -20,6 +20,8 @@
       )
 )
 #' Returns the POSIXt value of a given name
+#' @param object An object of class \link{Refperiode-class}
+#' @param id one of "jour", "semaine", "quinzaine", "mois"
 #' @return "a character to be used in seq.POSIXt
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @examples 

Modified: pkg/stacomir/R/create_generic.r
===================================================================
--- pkg/stacomir/R/create_generic.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/create_generic.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -32,7 +32,8 @@
 setGeneric("charge_avec_filtre",def=function(object,...) standardGeneric("charge_avec_filtre"))
 #setGeneric("connect",def=function(object,...) standardGeneric("connect")) # package stacomirtools
 #' Generic method for plot
-#' @param object Object
+#' @param x passed by the generic
+#' @param y passed by the generic
 #' @param ... Additional parms
 #' @author cedric.briand
 setGeneric("plot",def=function(x,y,...) standardGeneric("plot"))

Modified: pkg/stacomir/R/fn_EcritBilanJournalier.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanJournalier.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/fn_EcritBilanJournalier.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -83,7 +83,7 @@
 			requete at sql=paste( "INSERT INTO ",get("sch",envir=envir_stacomi),"t_bilanmigrationjournalier_bjo (",			
 					"bjo_dis_identifiant,bjo_tax_code,bjo_std_code,bjo_annee,bjo_jour,bjo_valeur,bjo_labelquantite,bjo_horodateexport,bjo_org_code)",
 					" VALUES " ,"('",paste(t_bilanmigrationjournalier_bjo[i,],collapse="','"),"');",sep="")
-			requete<-stacomirtools::connect(requete) 
+			invisible(requete<-stacomirtools::connect(requete)) 
 			
 		} # end for
 		if (!silent){
@@ -143,7 +143,7 @@
 					"bjo_dis_identifiant,bjo_tax_code,bjo_std_code,bjo_annee,bjo_jour,bjo_valeur,bjo_labelquantite,bjo_horodateexport,bjo_org_code)",
 					" VALUES " ,
 					"('",paste(t_bilanmigrationjournalier_bjo[i,],collapse="','"),"');",sep="")
-			requete<-stacomirtools::connect(requete)   
+			invisible(requete<-stacomirtools::connect(requete))   
 		} # end for
 		RODBC::odbcClose(requete at connection)
 		if (!silent) funout(paste(get("msg",envir=envir_stacomi)$fn_EcritBilanJournalier.5,"\n"))

Modified: pkg/stacomir/R/fn_EcritBilanMensuel.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanMensuel.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/fn_EcritBilanMensuel.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -33,7 +33,7 @@
 		requete at sql=paste("INSERT INTO ",get("sch",envir=envir_stacomi),"t_bilanMigrationMensuel_bme (",			
 				"bme_dis_identifiant,bme_tax_code,bme_std_code,bme_annee,bme_labelquantite,bme_valeur,bme_mois,bme_horodateexport,bme_org_code)",
 				" VALUES ('",paste(t_bilanmigrationmensuel_bme[i,],collapse="','"),"');",sep="")
-		requete<-stacomirtools::connect(requete)   
+		invisible(requete<-stacomirtools::connect(requete))   
 	} # end for
 	odbcClose(requete at connection)
 funout(paste(get("msg",envir=envir_stacomi)$fn_EcritBilanMensuel.1,"\n"))	

Modified: pkg/stacomir/R/fn_table_per_dis.r
===================================================================
--- pkg/stacomir/R/fn_table_per_dis.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/fn_table_per_dis.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -2,16 +2,16 @@
 #' 
 #' 
 #' 
-#' @param typeperiode ref.tr_typearretdisp_tar(per_tar_code) the code of the
+#' @param typeperiode Ref.tr_typearretdisp_tar(per_tar_code) the code of the
 #' period (see table ref.tr_typearretdisp_tar)
-#' @param tempsdebut ref.tr_typearretdisp_tar(per_date_debut) starting
+#' @param tempsdebut Ref.tr_typearretdisp_tar(per_date_debut) starting
 #' timestamp of the period
 #' @param tempsfin The posgres column ref.tr_typearretdisp_tar(per_date_fin) ending timestamp of
 #' the period
-#' @param Libelle The posgres column ref.tr_typearretdisp_tar(libelle )description of the period
+#' @param libelle The posgres column ref.tr_typearretdisp_tar(libelle )description of the period
 #' type
 #' @param date Boolean, should the function return a POSIXt or date value
-#' @return listeg A list
+#' @return  A list
 #' @note returns either POSIXt or date if date=TRUE
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 fn_table_per_dis <-function(typeperiode, tempsdebut, tempsfin,libelle,date=TRUE){

Modified: pkg/stacomir/R/stacomi.r
===================================================================
--- pkg/stacomir/R/stacomi.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/stacomi.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -315,7 +315,7 @@
 	assign("login_window",login_window,envir=envir_stacomi)
    # the first messages are necessary for the first access to the database, they are in French
 	msg<-messages()
-	mylinks=chargecsv()
+	mylinks=chargecsv(database_expected)
 	baseODBC=mylinks[["baseODBC"]]
 	datawd=mylinks[["datawd"]]
 	lang=mylinks[["lang"]]	

Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/R/utilitaires.r	2016-09-09 17:53:25 UTC (rev 203)
@@ -107,25 +107,32 @@
 #' 	\code{uid}, \code{pwd} are identifier and password to connect to the database, they should
 #' correspond to your own schema in the database. \code{pgwd} is the path to the R
 #' source if you plan not to use the compiler but run manually using inst/config/stacomi_manual_launch.R for development.\cr
-#' 	\code{datawd}, is the the
+#' \code{datawd}, is the
 #' directory where you want to place the outputs, mostly tables, from the
 #' program, default to ~//CalcmigData lang, is either one of French, English or
 #' Spanish
 #' 	other fields correspond to sqldf options.
+#' @param database expected Are the program (stacomi directory) and database expected to be installed,
+#' this argument is necessary to pass tests on system where stacomi is not installed (e.g. R-forge)
 #' @note A version of the calcmig.csv is packaged in the config directory of the stacomiR library.
 #' 
 #' @return a list with the datawd place and the baseODBC vector
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
 #' @keywords internal
-chargecsv=function(){ 
+chargecsv=function(database_expected){ 
 	#library(XML)  # chargement du package XML
 	options(guiToolkit = "RGtk2")
 	# use of stringr package 
 	# by default the csv file is in C:/Program Files/stacomi/ and we don't want to change that
-	filecsv<-"C:/Program Files/stacomi/calcmig.csv"
 	# note this will only be tested once the program is packages otherwise the path is inst/config/calcmig.csv
 	filecsvR=file.path(.libPaths(),"stacomiR","config","calcmig.csv")
+	if (database_expected) {
+		filecsv<-"C:/Program Files/stacomi/calcmig.csv"
+	} else {
+		filecsv<-filecsvR
+	}
+
 	
 	test<-file.access(filecsv,0)==0
 	# if the file does not open, we will switch to the file located within the package

Deleted: pkg/stacomir/inst/config/testfile.R
===================================================================
--- pkg/stacomir/inst/config/testfile.R	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/inst/config/testfile.R	2016-09-09 17:53:25 UTC (rev 203)
@@ -1,73 +0,0 @@
-source("F:/workspace/stacomir/branch0.5/stacomir/inst/config/stacomi.r")
-# interface_graphique()
-bilanMigrationMult=new("BilanMigrationMult")
-
-
-
-bilanMigrationMult=load(bilanMigrationMult,
-dc=c(5,6,12),
-taxons=c("Anguilla anguilla"),
-stades=c("AGG","AGJ","CIV"),datedebut="2011-01-01",datefin="2011-12-31")
-
-bilanMigrationMult=calcule(bilanMigrationMult)
-hbilanMigrationMultgraph()
-hbilanMigrationMultgraph2()
-hbilanMigrationMultgraph3()
-
-
-source("F:/workspace/stacomir/branch0.5/stacomir/inst/config/stacomi.r")
-# les options sont recuperees par defaut...
-# je les change pour les tests sur migration
-ls(envir=envir_stacomi) # liste des objects presents dans l'environnement de travail cree par le package
-baseODBC<-get("baseODBC",envir=envir_stacomi)
-baseODBC[c(2,3)]<-rep("migradour",2)
-# reassignation dans l'environnement de travail
-assign("baseODBC",baseODBC,envir_stacomi)
-sch<-get("sch",envir=envir_stacomi) # "iav."
-assign("sch","migradour.",envir_stacomi)
-rm(baseODBC,sch) # j'enleve les objects de l'environnement global
-
-options(sqldf.RPostgreSQL.user = "migradour", 
-		sqldf.RPostgreSQL.password ="migradour",
-		sqldf.RPostgreSQL.dbname = "bd_contmig_nat",
-		sqldf.RPostgreSQL.host = "localhost",#  1.100.1.6
-		sqldf.RPostgreSQL.port = "5432")
-sqldf("SELECT
-ouv_sta_code as sta_code,
-ouv_code,
-ouv_libelle,
-dis2.dis_identifiant as df,
-dis2.dis_commentaires as df_commentaires,
-dif_code,
-dis1.dis_identifiant as dc, 
-dis1.dis_commentaires as dc_commentaires,
-dic_code             
-from migradour.tg_dispositif_dis dis1
-JOIN migradour.t_dispositifcomptage_dic ON dic_dis_identifiant=dis_identifiant
-JOIN migradour.t_dispositiffranchissement_dif dif ON dic_dif_identifiant=dif_dis_identifiant
-JOIN migradour.tg_dispositif_dis dis2 ON dif_dis_identifiant=dis2.dis_identifiant
-JOIN migradour.t_ouvrage_ouv ouv ON dif_ouv_identifiant=ouv_identifiant")
-#1     ArtixPasse 20
-#2     SordePasse 32
-#3   SCqAscenseur 22
-#4  GuerlainPasse 33
-#5     SoeixPasse 34
-#6  CherautePasse 35
-#7   ChopoloPasse 36
-#8      OlhaPasse 39
-#9    HalsouPasse 37
-#10  UxondoaPasse 38
-#11  MasseysPasse 40
-#12    PuyooPasse 43
-# Baigts ?
-# interface_graphique() # pour lancer avec l'interface
-bilanMigrationMult=new("BilanMigrationMult")
-bilanMigrationMult=load(bilanMigrationMult,dc=c(20,22,32,33,34,35,36,37,38,39,40),
-		taxons=c("Oncorhynchus mykiss","Salmo salar","Salmo trutta trutta"),
-		stades=c("11","IND","SML"),
-		datedebut="01/01/2013",
-		datefin="31/12/2013")
-bilanMigrationMult=calcule(bilanMigrationMult)
-hbilanMigrationMultgraph()
-hbilanMigrationMultgraph3()
-

Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2016-09-09 17:53:04 UTC (rev 202)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2016-09-09 17:53:25 UTC (rev 203)
@@ -16,7 +16,7 @@
 
 test_that("Test that ODBC link exists and has the right length",{
 			require(stacomiR)
-			result<-chargecsv();
+			result<-chargecsv(database_expected=TRUE);
 			expect_equal(length(result),4)
 			expect_equal(length(result$baseODBC),3)
 			expect_equal(length(result$sqldf),5)
@@ -29,7 +29,7 @@
 	require(stacomiR)
 	envir_stacomi <<- new.env(parent = emptyenv())
 	msg<-messages()
-	mylinks=chargecsv()
+	mylinks=chargecsv(database_expected=TRUE)
 	baseODBC=mylinks[["baseODBC"]]	
 	con=new("ConnectionODBC")	
 	con at baseODBC=baseODBC
@@ -44,7 +44,7 @@
 			require(stacomiR)
 			envir_stacomi <<- new.env(parent = emptyenv())
 			msg<-messages()
-			mylinks=chargecsv()
+			mylinks=chargecsv(database_expected=TRUE)
 			baseODBC=mylinks[["baseODBC"]]	
 			requete=new("RequeteODBC")
 			requete at baseODBC<-baseODBC
@@ -59,7 +59,7 @@
 			require(stacomiR)
 			envir_stacomi <<- new.env(parent = emptyenv())
 			msg<-messages()
-			mylinks=chargecsv()
+			mylinks=chargecsv(database_expected=TRUE)
 			baseODBC=mylinks[["baseODBC"]]	
 			sch<-paste(baseODBC[2],".",sep="")
 			requete=new("RequeteODBC")
@@ -112,22 +112,25 @@
 		{
 			envir_stacomi <<- new.env(parent = emptyenv())
 			msg<-messages()
-			mylinks=chargecsv()
+			mylinks=chargecsv(database_expected=TRUE)
 			baseODBC=mylinks[["baseODBC"]]	
 			assign("baseODBC",baseODBC,envir=envir_stacomi)
 			object=new("RefMsg")
 			object<-charge(object)	
 			expect_true(nrow(object at messager)>0)
+			rm("envir_stacomi",envir =.GlobalEnv)
 		})
 
 test_that("Test that  messages without connection are loaded and of the same length",
 		{
+			require(stacomiR)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			assign("lang","English",envir=envir_stacomi)	
 			object=new("RefMsg")
 			object<-createmessage(object,TRUE)	
 			msgbase<-get("msg",envir=envir_stacomi)
-			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
+			
+			
 			msg<-get("msg",envir=envir_stacomi)
 			# objects should have the same length but different languages
 			expect_identical(length(msg),length(msgbase))

Added: pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R	                        (rev 0)
+++ pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R	2016-09-09 17:53:25 UTC (rev 203)
@@ -0,0 +1,7 @@
+# TODO: Add comment
+# 
+# Author: cedric.briand
+###############################################################################
+
+
+



More information about the Stacomir-commits mailing list