diff --git a/ZScoDoc.py b/ZScoDoc.py index 83732b4d..2e2c1c1d 100644 --- a/ZScoDoc.py +++ b/ZScoDoc.py @@ -284,6 +284,7 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp raise ValueError("nom de departement invalide") if not pass2: # 1- Creation de repertoire Dept + log("creating Zope folder " + DeptId) add_method = self.manage_addProduct["OFSP"].manage_addFolder add_method(DeptId, title="Site dept. " + DeptId) @@ -291,10 +292,12 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp if not pass2: # 2- Creation du repertoire Fotos + log("creating Zope folder %s/Fotos" % DeptId) add_method = DeptFolder.manage_addProduct["OFSP"].manage_addFolder add_method("Fotos", title="Photos identites " + DeptId) # 3- Creation instance ScoDoc + log("creating Zope ZScolar instance") add_method = DeptFolder.manage_addProduct["ScoDoc"].manage_addZScolarForm return add_method(DeptId, REQUEST=REQUEST) diff --git a/ZScolar.py b/ZScolar.py index d47a3060..2b8f22b1 100644 --- a/ZScolar.py +++ b/ZScolar.py @@ -2037,49 +2037,8 @@ function tweakmenu( gname ) { ) if not edit: - # creation d'un etudiant - etudid = scolars.etudident_create( - cnx, tf[2], context=self, REQUEST=REQUEST - ) - # crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !) - adresse_id = scolars.adresse_create( - cnx, - { - "etudid": etudid, - "typeadresse": "domicile", - "description": "(creation individuelle)", - }, - ) - - # event - scolars.scolar_events_create( - cnx, - args={ - "etudid": etudid, - "event_date": time.strftime("%d/%m/%Y"), - "formsemestre_id": None, - "event_type": "CREATION", - }, - ) - # log - logdb( - REQUEST, - cnx, - method="etudident_edit_form", - etudid=etudid, - msg="creation initiale", - ) - etud = scolars.etudident_list(cnx, {"etudid": etudid})[0] - self.fillEtudsInfo([etud]) - etud["url"] = "ficheEtud?etudid=%(etudid)s" % etud - sco_news.add( - self, - REQUEST, - typ=NEWS_INSCR, - object=None, # pas d'object pour ne montrer qu'un etudiant - text='Nouvel étudiant %(nomprenom)s' % etud, - url=etud["url"], - ) + etud = scolars.create_etud(self, cnx, args=tf[2], REQUEST=REQUEST) + etudid = etud["etudid"] else: # modif d'un etudiant scolars.etudident_edit(cnx, tf[2], context=self, REQUEST=REQUEST) diff --git a/config/create_dept.sh b/config/create_dept.sh index 4b39b628..ee072ef6 100755 --- a/config/create_dept.sh +++ b/config/create_dept.sh @@ -13,27 +13,45 @@ source config.sh source utils.sh -check_uid_root $0 +check_uid_root "$0" +usage() { + echo "$0 [-n DEPT]" + echo "(default to interactive mode)" + exit 1 +} +[ $# = 0 ] || [ $# = 2 ] || usage -echo -n "Nom du departement (un mot sans ponctuation, exemple \"Info\"): " -read DEPT +if [ "$1" = "-n" ] +then + interactive=0 + if [ $# -lt 2 ] + then + usage + fi + DEPT=$2 +else + interactive=1 + echo -n "Nom du departement (un mot sans ponctuation, exemple \"Info\"): " + read -r DEPT +fi if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]] then echo 'Nom de departement invalide !' - exit 1 + exit 2 fi export DEPT -export db_name=SCO$(to_upper "$DEPT") +db_name=SCO$(to_upper "$DEPT") +export db_name cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg -if [ -e $cfg_pathname ] +if [ -e "$cfg_pathname" ] then - echo 'Erreur: Il existe deja une configuration pour "'$DEPT'"' + echo 'Erreur: Il existe deja une configuration pour "'"$DEPT"'"' exit 1 fi @@ -41,29 +59,32 @@ fi init_postgres_user # ----------------------- Create database -su -c ./create_database.sh $POSTGRES_SUPERUSER +su -c ./create_database.sh "$POSTGRES_SUPERUSER" # ----------------------- Create tables # POSTGRES_USER == regular unix user (www-data) -su -c ./initialize_database.sh $POSTGRES_USER +su -c ./initialize_database.sh "$POSTGRES_USER" # ----------------------- Enregistre fichier config -echo "dbname="$db_name > $cfg_pathname +echo "dbname=${db_name}" > "$cfg_pathname" -# ----------------------- Force mise à jour -echo -n "Voulez vous mettre a jour ScoDoc (tres recommande) ? (y/n) [y] " -read ans -if [ "$(norm_ans "$ans")" != 'N' ] + +if [ "$interactive" = 1 ] then - (cd "$SCODOC_DIR/config"; ./upgrade.sh) + # ----------------------- Force mise à jour + echo -n "Voulez vous mettre a jour ScoDoc (tres recommande) ? (y/n) [y] " + read -r ans + if [ "$(norm_ans "$ans")" != 'N' ] + then + (cd "$SCODOC_DIR/config" || terminate "no config directory"; ./upgrade.sh) + fi + # ----------------------- + echo + echo " Departement $DEPT cree" + echo + echo " Attention: la base de donnees n'a pas de copies de sauvegarde" + echo + echo " Maintenant, vous pouvez ajouter le departement via l'application web" + echo " en suivant le lien \"Administration de ScoDoc\" sur la page d'accueil." + echo fi - -# ----------------------- -echo -echo " Departement $DEPT cree" -echo -echo " Attention: la base de donnees n'a pas de copies de sauvegarde" -echo -echo " Maintenant, vous pouvez ajouter le departement via l'application web" -echo " en suivant le lien \"Administration de ScoDoc\" sur la page d'accueil." -echo diff --git a/config/delete_dept.sh b/config/delete_dept.sh index b0e9919a..3f2f05f6 100755 --- a/config/delete_dept.sh +++ b/config/delete_dept.sh @@ -18,46 +18,64 @@ source config.sh source utils.sh check_uid_root $0 - -echo -echo "Ce script supprime la base de donnees ScoDoc d'un departement" -echo -echo "Attention: le departement doit au prealable avoir ete supprime via l'interface web !" -echo "faites le AVANT d'executer ce script !!!" -echo -echo -n "Nom du departement a supprimer (un mot sans ponctuation, exemple \"Info\"): " -read DEPT +usage() { + echo "$0 [-n DEPT]" + echo "(default to interactive mode)" + exit 1 +} +[ $# = 0 ] || [ $# = 2 ] || usage +if [ "$1" = "-n" ] +then + interactive=0 + if [ $# -lt 2 ] + then + usage + fi + DEPT=$2 +else + interactive=1 + echo + echo "Ce script supprime la base de donnees ScoDoc d'un departement" + echo + echo "Attention: le departement doit au prealable avoir ete supprime via l'interface web !" + echo "faites le AVANT d'executer ce script !!!" + echo + echo -n "Nom du departement a supprimer (un mot sans ponctuation, exemple \"Info\"): " + read -r DEPT +fi if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]] then echo "Nom de departement invalide !" exit 1 fi - export DEPT cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg -if [ -e $cfg_pathname ] +if [ -e "$cfg_pathname" ] then # arret de ScoDoc scodocctl stop # suppression de la base postgres - db_name=$(cat $cfg_pathname | sed '/^dbname=*/!d; s///;q') + db_name=$(cat "$cfg_pathname" | sed '/^dbname=*/!d; s///;q') echo "suppression de la base postgres $db_name" - su -c "dropdb $db_name" $POSTGRES_SUPERUSER || terminate "ne peux supprimer base de donnees $db_name" + su -c "dropdb $db_name" "$POSTGRES_SUPERUSER" || terminate "ne peux supprimer base de donnees $db_name" # suppression du fichier de config - /bin/rm -f $cfg_pathname || terminate "ne peux supprimer $cfg_pathname" + /bin/rm -f "$cfg_pathname" || terminate "ne peux supprimer $cfg_pathname" # relance ScoDoc - echo -n "Demarrer le serveur ScoDoc ? (y/n) [n]" - read ans - if [ "$(norm_ans "$ans")" = 'Y' ] + if [ "$interactive" = 1 ] then - scodocctl start + echo -n "Demarrer le serveur ScoDoc ? (y/n) [n]" + read -r ans + if [ "$(norm_ans "$ans")" = 'Y' ] + then + scodocctl start + fi fi exit 0 else - echo 'Erreur: pas de configuration trouvee pour "'$DEPT'"' + echo 'Erreur: pas de configuration trouvee pour "'"$DEPT"'"' exit 1 fi diff --git a/debug.py b/debug.py index b8c0d763..55c64e26 100644 --- a/debug.py +++ b/debug.py @@ -31,6 +31,8 @@ nt = context.Notes._getNotesCache().get_NotesTable(context.Notes, formsemestre_i """ +import pdb + from notesdb import * from notes_log import log from sco_utils import * @@ -78,6 +80,9 @@ class FakeUser: def has_permission(self, op, context): return True + def has_role(self, role): + return True + class DummyResponse: """Emulation vide de Reponse http Zope""" @@ -104,6 +109,7 @@ class DummyRequest: self.URL1 = self.URL self.URL0 = self.URL self.BASE0 = "localhost" + self.REMOTE_HOST = "localhost" self.REMOTE_ADDR = "127.0.0.1" self.HTTP_REFERER = "" self.REQUEST_METHOD = "get" diff --git a/notes_log.py b/notes_log.py index a2b29a9e..03583375 100644 --- a/notes_log.py +++ b/notes_log.py @@ -34,7 +34,7 @@ class _logguer: if LOG_FILENAME: path = os.path.join(self.directory, LOG_FILENAME) self.file = open(path, "a") - self("new _logguer") + self("new _logguer (%s)" % path) else: self.file = None # logging disabled diff --git a/notesdb.py b/notesdb.py index 409f0bf3..5bdbcf40 100644 --- a/notesdb.py +++ b/notesdb.py @@ -248,8 +248,7 @@ def DBDelete(cnx, table, colid, val, commit=False): class EditableTable: - """ --- generic class: SQL table with create/edit/list/delete - """ + """--- generic class: SQL table with create/edit/list/delete""" def __init__( self, @@ -377,7 +376,11 @@ class EditableTable: # format value for title in vals.keys(): if self.input_formators.has_key(title): - vals[title] = self.input_formators[title](vals[title]) + try: + vals[title] = self.input_formators[title](vals[title]) + except: + log("exception while converting %s=%s" % (title, vals[title])) + raise DBUpdateArgs( cnx, self.table_name, diff --git a/sco_synchro_etuds.py b/sco_synchro_etuds.py index 1bfef292..2c32c1fd 100644 --- a/sco_synchro_etuds.py +++ b/sco_synchro_etuds.py @@ -28,6 +28,8 @@ """Synchronisation des listes d'étudiants avec liste portail (Apogée) """ +import time +import pprint from sco_utils import ScoEtudInscrit, annee_scolaire_debut, log, ScoValueError from notesdb import ScoDocCursor @@ -42,8 +44,6 @@ import sco_formsemestre_inscriptions import sco_formsemestre_status from sco_news import NEWS_INSCR, NEWS_NOTE, NEWS_FORM, NEWS_SEM, NEWS_MISC -import time - # Clés utilisées pour la synchro EKEY_APO = "nip" EKEY_SCO = "code_nip" @@ -695,7 +695,7 @@ def do_import_etud_admission( "codelycee": get_opt_str(etud, "lycee"), "boursier": get_opt_str(etud, "bourse"), } - log("do_import_etud_admission: etud=%s" % etud) + log("do_import_etud_admission: etud=%s" % pprint.pformat(etud)) al = scolars.admission_list(cnx, args={"etudid": etudid}) if not al: scolars.admission_create(cnx, args) # -> adm_id diff --git a/scolars.py b/scolars.py index f39f9d92..b3e91e53 100644 --- a/scolars.py +++ b/scolars.py @@ -25,7 +25,7 @@ # ############################################################################## -""" Acces donnees etudiants +""" Accès donnees etudiants """ from sco_utils import * @@ -35,7 +35,7 @@ from TrivialFormulator import TrivialFormulator import safehtml from scolog import logdb from notes_table import * - +import sco_news # XXXXXXXXX HACK: zope 2.7.7 bug turaround ? import locale @@ -618,6 +618,59 @@ def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True): return args +def create_etud(context, cnx, args={}, REQUEST=None): + """Creation d'un étudiant. génère aussi évenement et "news". + + Args: + args: dict avec les attributs de l'étudiant + + Returns: + etud, l'étudiant créé. + """ + # creation d'un etudiant + etudid = etudident_create(cnx, args, context=context, REQUEST=REQUEST) + # crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !) + _ = adresse_create( + cnx, + { + "etudid": etudid, + "typeadresse": "domicile", + "description": "(creation individuelle)", + }, + ) + + # event + scolar_events_create( + cnx, + args={ + "etudid": etudid, + "event_date": time.strftime("%d/%m/%Y"), + "formsemestre_id": None, + "event_type": "CREATION", + }, + ) + # log + logdb( + REQUEST, + cnx, + method="etudident_edit_form", + etudid=etudid, + msg="creation initiale", + ) + etud = scolars.etudident_list(cnx, {"etudid": etudid})[0] + context.fillEtudsInfo([etud]) + etud["url"] = "ficheEtud?etudid=%(etudid)s" % etud + sco_news.add( + context, + REQUEST, + typ=sco_news.NEWS_INSCR, + object=None, # pas d'object pour ne montrer qu'un etudiant + text='Nouvel étudiant %(nomprenom)s' % etud, + url=etud["url"], + ) + return etud + + # ---------- "EVENTS" _scolar_eventsEditor = EditableTable( "scolar_events", diff --git a/scotests/__init__.py b/scotests/__init__.py new file mode 100644 index 00000000..792d6005 --- /dev/null +++ b/scotests/__init__.py @@ -0,0 +1 @@ +# diff --git a/tests/demo/__init__.py b/scotests/demo/__init__.py similarity index 100% rename from tests/demo/__init__.py rename to scotests/demo/__init__.py diff --git a/tests/demo/demo_reset_noms.py b/scotests/demo/demo_reset_noms.py similarity index 100% rename from tests/demo/demo_reset_noms.py rename to scotests/demo/demo_reset_noms.py diff --git a/tests/demo/gen_nomprenoms.py b/scotests/demo/gen_nomprenoms.py similarity index 100% rename from tests/demo/gen_nomprenoms.py rename to scotests/demo/gen_nomprenoms.py diff --git a/tests/demo/noms.txt b/scotests/demo/noms.txt similarity index 100% rename from tests/demo/noms.txt rename to scotests/demo/noms.txt diff --git a/tests/demo/prenoms-f.txt b/scotests/demo/prenoms-f.txt similarity index 100% rename from tests/demo/prenoms-f.txt rename to scotests/demo/prenoms-f.txt diff --git a/tests/demo/prenoms-h.txt b/scotests/demo/prenoms-h.txt similarity index 100% rename from tests/demo/prenoms-h.txt rename to scotests/demo/prenoms-h.txt diff --git a/tests/demo/prenoms.txt b/scotests/demo/prenoms.txt similarity index 100% rename from tests/demo/prenoms.txt rename to scotests/demo/prenoms.txt diff --git a/tests/fakeportal/etapes.xml b/scotests/fakeportal/etapes.xml similarity index 100% rename from tests/fakeportal/etapes.xml rename to scotests/fakeportal/etapes.xml diff --git a/tests/fakeportal/etud_minimal_template.xml b/scotests/fakeportal/etud_minimal_template.xml similarity index 100% rename from tests/fakeportal/etud_minimal_template.xml rename to scotests/fakeportal/etud_minimal_template.xml diff --git a/tests/fakeportal/etud_template.xml b/scotests/fakeportal/etud_template.xml similarity index 100% rename from tests/fakeportal/etud_template.xml rename to scotests/fakeportal/etud_template.xml diff --git a/tests/fakeportal/faces/cs00000.jpg b/scotests/fakeportal/faces/cs00000.jpg similarity index 100% rename from tests/fakeportal/faces/cs00000.jpg rename to scotests/fakeportal/faces/cs00000.jpg diff --git a/tests/fakeportal/faces/cs00001.jpg b/scotests/fakeportal/faces/cs00001.jpg similarity index 100% rename from tests/fakeportal/faces/cs00001.jpg rename to scotests/fakeportal/faces/cs00001.jpg diff --git a/tests/fakeportal/faces/cs00002.jpg b/scotests/fakeportal/faces/cs00002.jpg similarity index 100% rename from tests/fakeportal/faces/cs00002.jpg rename to scotests/fakeportal/faces/cs00002.jpg diff --git a/tests/fakeportal/faces/cs00003.jpg b/scotests/fakeportal/faces/cs00003.jpg similarity index 100% rename from tests/fakeportal/faces/cs00003.jpg rename to scotests/fakeportal/faces/cs00003.jpg diff --git a/tests/fakeportal/faces/cs00004.jpg b/scotests/fakeportal/faces/cs00004.jpg similarity index 100% rename from tests/fakeportal/faces/cs00004.jpg rename to scotests/fakeportal/faces/cs00004.jpg diff --git a/tests/fakeportal/faces/cs00005.jpg b/scotests/fakeportal/faces/cs00005.jpg similarity index 100% rename from tests/fakeportal/faces/cs00005.jpg rename to scotests/fakeportal/faces/cs00005.jpg diff --git a/tests/fakeportal/faces/cs00006.jpg b/scotests/fakeportal/faces/cs00006.jpg similarity index 100% rename from tests/fakeportal/faces/cs00006.jpg rename to scotests/fakeportal/faces/cs00006.jpg diff --git a/tests/fakeportal/faces/cs00007.jpg b/scotests/fakeportal/faces/cs00007.jpg similarity index 100% rename from tests/fakeportal/faces/cs00007.jpg rename to scotests/fakeportal/faces/cs00007.jpg diff --git a/tests/fakeportal/faces/cs00008.jpg b/scotests/fakeportal/faces/cs00008.jpg similarity index 100% rename from tests/fakeportal/faces/cs00008.jpg rename to scotests/fakeportal/faces/cs00008.jpg diff --git a/tests/fakeportal/faces/cs00009.jpg b/scotests/fakeportal/faces/cs00009.jpg similarity index 100% rename from tests/fakeportal/faces/cs00009.jpg rename to scotests/fakeportal/faces/cs00009.jpg diff --git a/tests/fakeportal/faces/cs00010.jpg b/scotests/fakeportal/faces/cs00010.jpg similarity index 100% rename from tests/fakeportal/faces/cs00010.jpg rename to scotests/fakeportal/faces/cs00010.jpg diff --git a/tests/fakeportal/faces/cs00011.jpg b/scotests/fakeportal/faces/cs00011.jpg similarity index 100% rename from tests/fakeportal/faces/cs00011.jpg rename to scotests/fakeportal/faces/cs00011.jpg diff --git a/tests/fakeportal/faces/cs00012.jpg b/scotests/fakeportal/faces/cs00012.jpg similarity index 100% rename from tests/fakeportal/faces/cs00012.jpg rename to scotests/fakeportal/faces/cs00012.jpg diff --git a/tests/fakeportal/faces/cs00013.jpg b/scotests/fakeportal/faces/cs00013.jpg similarity index 100% rename from tests/fakeportal/faces/cs00013.jpg rename to scotests/fakeportal/faces/cs00013.jpg diff --git a/tests/fakeportal/faces/cs00014.jpg b/scotests/fakeportal/faces/cs00014.jpg similarity index 100% rename from tests/fakeportal/faces/cs00014.jpg rename to scotests/fakeportal/faces/cs00014.jpg diff --git a/tests/fakeportal/faces/cs00015.jpg b/scotests/fakeportal/faces/cs00015.jpg similarity index 100% rename from tests/fakeportal/faces/cs00015.jpg rename to scotests/fakeportal/faces/cs00015.jpg diff --git a/tests/fakeportal/faces/cs00016.jpg b/scotests/fakeportal/faces/cs00016.jpg similarity index 100% rename from tests/fakeportal/faces/cs00016.jpg rename to scotests/fakeportal/faces/cs00016.jpg diff --git a/tests/fakeportal/faces/cs00017.jpg b/scotests/fakeportal/faces/cs00017.jpg similarity index 100% rename from tests/fakeportal/faces/cs00017.jpg rename to scotests/fakeportal/faces/cs00017.jpg diff --git a/tests/fakeportal/faces/cs00018.jpg b/scotests/fakeportal/faces/cs00018.jpg similarity index 100% rename from tests/fakeportal/faces/cs00018.jpg rename to scotests/fakeportal/faces/cs00018.jpg diff --git a/tests/fakeportal/faces/cs00019.jpg b/scotests/fakeportal/faces/cs00019.jpg similarity index 100% rename from tests/fakeportal/faces/cs00019.jpg rename to scotests/fakeportal/faces/cs00019.jpg diff --git a/tests/fakeportal/faces/cs00020.jpg b/scotests/fakeportal/faces/cs00020.jpg similarity index 100% rename from tests/fakeportal/faces/cs00020.jpg rename to scotests/fakeportal/faces/cs00020.jpg diff --git a/tests/fakeportal/faces/cs00021.jpg b/scotests/fakeportal/faces/cs00021.jpg similarity index 100% rename from tests/fakeportal/faces/cs00021.jpg rename to scotests/fakeportal/faces/cs00021.jpg diff --git a/tests/fakeportal/faces/cs00022.jpg b/scotests/fakeportal/faces/cs00022.jpg similarity index 100% rename from tests/fakeportal/faces/cs00022.jpg rename to scotests/fakeportal/faces/cs00022.jpg diff --git a/tests/fakeportal/faces/cs00023.jpg b/scotests/fakeportal/faces/cs00023.jpg similarity index 100% rename from tests/fakeportal/faces/cs00023.jpg rename to scotests/fakeportal/faces/cs00023.jpg diff --git a/tests/fakeportal/faces/cs00024.jpg b/scotests/fakeportal/faces/cs00024.jpg similarity index 100% rename from tests/fakeportal/faces/cs00024.jpg rename to scotests/fakeportal/faces/cs00024.jpg diff --git a/tests/fakeportal/faces/cs00025.jpg b/scotests/fakeportal/faces/cs00025.jpg similarity index 100% rename from tests/fakeportal/faces/cs00025.jpg rename to scotests/fakeportal/faces/cs00025.jpg diff --git a/tests/fakeportal/faces/cs00026.jpg b/scotests/fakeportal/faces/cs00026.jpg similarity index 100% rename from tests/fakeportal/faces/cs00026.jpg rename to scotests/fakeportal/faces/cs00026.jpg diff --git a/tests/fakeportal/faces/cs00027.jpg b/scotests/fakeportal/faces/cs00027.jpg similarity index 100% rename from tests/fakeportal/faces/cs00027.jpg rename to scotests/fakeportal/faces/cs00027.jpg diff --git a/tests/fakeportal/faces/cs00028.jpg b/scotests/fakeportal/faces/cs00028.jpg similarity index 100% rename from tests/fakeportal/faces/cs00028.jpg rename to scotests/fakeportal/faces/cs00028.jpg diff --git a/tests/fakeportal/faces/cs00029.jpg b/scotests/fakeportal/faces/cs00029.jpg similarity index 100% rename from tests/fakeportal/faces/cs00029.jpg rename to scotests/fakeportal/faces/cs00029.jpg diff --git a/tests/fakeportal/faces/cs00030.jpg b/scotests/fakeportal/faces/cs00030.jpg similarity index 100% rename from tests/fakeportal/faces/cs00030.jpg rename to scotests/fakeportal/faces/cs00030.jpg diff --git a/tests/fakeportal/faces/cs00031.jpg b/scotests/fakeportal/faces/cs00031.jpg similarity index 100% rename from tests/fakeportal/faces/cs00031.jpg rename to scotests/fakeportal/faces/cs00031.jpg diff --git a/tests/fakeportal/faces/cs00032.jpg b/scotests/fakeportal/faces/cs00032.jpg similarity index 100% rename from tests/fakeportal/faces/cs00032.jpg rename to scotests/fakeportal/faces/cs00032.jpg diff --git a/tests/fakeportal/faces/cs00033.jpg b/scotests/fakeportal/faces/cs00033.jpg similarity index 100% rename from tests/fakeportal/faces/cs00033.jpg rename to scotests/fakeportal/faces/cs00033.jpg diff --git a/tests/fakeportal/faces/cs00034.jpg b/scotests/fakeportal/faces/cs00034.jpg similarity index 100% rename from tests/fakeportal/faces/cs00034.jpg rename to scotests/fakeportal/faces/cs00034.jpg diff --git a/tests/fakeportal/faces/cs00035.jpg b/scotests/fakeportal/faces/cs00035.jpg similarity index 100% rename from tests/fakeportal/faces/cs00035.jpg rename to scotests/fakeportal/faces/cs00035.jpg diff --git a/tests/fakeportal/faces/cs00036.jpg b/scotests/fakeportal/faces/cs00036.jpg similarity index 100% rename from tests/fakeportal/faces/cs00036.jpg rename to scotests/fakeportal/faces/cs00036.jpg diff --git a/tests/fakeportal/faces/cs00037.jpg b/scotests/fakeportal/faces/cs00037.jpg similarity index 100% rename from tests/fakeportal/faces/cs00037.jpg rename to scotests/fakeportal/faces/cs00037.jpg diff --git a/tests/fakeportal/faces/cs00038.jpg b/scotests/fakeportal/faces/cs00038.jpg similarity index 100% rename from tests/fakeportal/faces/cs00038.jpg rename to scotests/fakeportal/faces/cs00038.jpg diff --git a/tests/fakeportal/faces/cs00039.jpg b/scotests/fakeportal/faces/cs00039.jpg similarity index 100% rename from tests/fakeportal/faces/cs00039.jpg rename to scotests/fakeportal/faces/cs00039.jpg diff --git a/tests/fakeportal/faces/cs00040.jpg b/scotests/fakeportal/faces/cs00040.jpg similarity index 100% rename from tests/fakeportal/faces/cs00040.jpg rename to scotests/fakeportal/faces/cs00040.jpg diff --git a/tests/fakeportal/faces/cs00041.jpg b/scotests/fakeportal/faces/cs00041.jpg similarity index 100% rename from tests/fakeportal/faces/cs00041.jpg rename to scotests/fakeportal/faces/cs00041.jpg diff --git a/tests/fakeportal/faces/cs00042.jpg b/scotests/fakeportal/faces/cs00042.jpg similarity index 100% rename from tests/fakeportal/faces/cs00042.jpg rename to scotests/fakeportal/faces/cs00042.jpg diff --git a/tests/fakeportal/faces/cs00043.jpg b/scotests/fakeportal/faces/cs00043.jpg similarity index 100% rename from tests/fakeportal/faces/cs00043.jpg rename to scotests/fakeportal/faces/cs00043.jpg diff --git a/tests/fakeportal/faces/cs00044.jpg b/scotests/fakeportal/faces/cs00044.jpg similarity index 100% rename from tests/fakeportal/faces/cs00044.jpg rename to scotests/fakeportal/faces/cs00044.jpg diff --git a/tests/fakeportal/faces/cs00045.jpg b/scotests/fakeportal/faces/cs00045.jpg similarity index 100% rename from tests/fakeportal/faces/cs00045.jpg rename to scotests/fakeportal/faces/cs00045.jpg diff --git a/tests/fakeportal/faces/cs00046.jpg b/scotests/fakeportal/faces/cs00046.jpg similarity index 100% rename from tests/fakeportal/faces/cs00046.jpg rename to scotests/fakeportal/faces/cs00046.jpg diff --git a/tests/fakeportal/faces/cs00047.jpg b/scotests/fakeportal/faces/cs00047.jpg similarity index 100% rename from tests/fakeportal/faces/cs00047.jpg rename to scotests/fakeportal/faces/cs00047.jpg diff --git a/tests/fakeportal/faces/cs00048.jpg b/scotests/fakeportal/faces/cs00048.jpg similarity index 100% rename from tests/fakeportal/faces/cs00048.jpg rename to scotests/fakeportal/faces/cs00048.jpg diff --git a/tests/fakeportal/faces/cs00049.jpg b/scotests/fakeportal/faces/cs00049.jpg similarity index 100% rename from tests/fakeportal/faces/cs00049.jpg rename to scotests/fakeportal/faces/cs00049.jpg diff --git a/tests/fakeportal/faces/cs00050.jpg b/scotests/fakeportal/faces/cs00050.jpg similarity index 100% rename from tests/fakeportal/faces/cs00050.jpg rename to scotests/fakeportal/faces/cs00050.jpg diff --git a/tests/fakeportal/faces/cs00051.jpg b/scotests/fakeportal/faces/cs00051.jpg similarity index 100% rename from tests/fakeportal/faces/cs00051.jpg rename to scotests/fakeportal/faces/cs00051.jpg diff --git a/tests/fakeportal/faces/cs00052.jpg b/scotests/fakeportal/faces/cs00052.jpg similarity index 100% rename from tests/fakeportal/faces/cs00052.jpg rename to scotests/fakeportal/faces/cs00052.jpg diff --git a/tests/fakeportal/faces/cs00053.jpg b/scotests/fakeportal/faces/cs00053.jpg similarity index 100% rename from tests/fakeportal/faces/cs00053.jpg rename to scotests/fakeportal/faces/cs00053.jpg diff --git a/tests/fakeportal/faces/cs00054.jpg b/scotests/fakeportal/faces/cs00054.jpg similarity index 100% rename from tests/fakeportal/faces/cs00054.jpg rename to scotests/fakeportal/faces/cs00054.jpg diff --git a/tests/fakeportal/faces/cs00055.jpg b/scotests/fakeportal/faces/cs00055.jpg similarity index 100% rename from tests/fakeportal/faces/cs00055.jpg rename to scotests/fakeportal/faces/cs00055.jpg diff --git a/tests/fakeportal/faces/cs00056.jpg b/scotests/fakeportal/faces/cs00056.jpg similarity index 100% rename from tests/fakeportal/faces/cs00056.jpg rename to scotests/fakeportal/faces/cs00056.jpg diff --git a/tests/fakeportal/faces/cs00057.jpg b/scotests/fakeportal/faces/cs00057.jpg similarity index 100% rename from tests/fakeportal/faces/cs00057.jpg rename to scotests/fakeportal/faces/cs00057.jpg diff --git a/tests/fakeportal/faces/cs00058.jpg b/scotests/fakeportal/faces/cs00058.jpg similarity index 100% rename from tests/fakeportal/faces/cs00058.jpg rename to scotests/fakeportal/faces/cs00058.jpg diff --git a/tests/fakeportal/faces/cs00059.jpg b/scotests/fakeportal/faces/cs00059.jpg similarity index 100% rename from tests/fakeportal/faces/cs00059.jpg rename to scotests/fakeportal/faces/cs00059.jpg diff --git a/tests/fakeportal/faces/cs00060.jpg b/scotests/fakeportal/faces/cs00060.jpg similarity index 100% rename from tests/fakeportal/faces/cs00060.jpg rename to scotests/fakeportal/faces/cs00060.jpg diff --git a/tests/fakeportal/faces/cs00061.jpg b/scotests/fakeportal/faces/cs00061.jpg similarity index 100% rename from tests/fakeportal/faces/cs00061.jpg rename to scotests/fakeportal/faces/cs00061.jpg diff --git a/tests/fakeportal/faces/cs00062.jpg b/scotests/fakeportal/faces/cs00062.jpg similarity index 100% rename from tests/fakeportal/faces/cs00062.jpg rename to scotests/fakeportal/faces/cs00062.jpg diff --git a/tests/fakeportal/faces/cs00063.jpg b/scotests/fakeportal/faces/cs00063.jpg similarity index 100% rename from tests/fakeportal/faces/cs00063.jpg rename to scotests/fakeportal/faces/cs00063.jpg diff --git a/tests/fakeportal/faces/cs00064.jpg b/scotests/fakeportal/faces/cs00064.jpg similarity index 100% rename from tests/fakeportal/faces/cs00064.jpg rename to scotests/fakeportal/faces/cs00064.jpg diff --git a/tests/fakeportal/faces/cs00065.jpg b/scotests/fakeportal/faces/cs00065.jpg similarity index 100% rename from tests/fakeportal/faces/cs00065.jpg rename to scotests/fakeportal/faces/cs00065.jpg diff --git a/tests/fakeportal/faces/cs00066.jpg b/scotests/fakeportal/faces/cs00066.jpg similarity index 100% rename from tests/fakeportal/faces/cs00066.jpg rename to scotests/fakeportal/faces/cs00066.jpg diff --git a/tests/fakeportal/faces/cs00067.jpg b/scotests/fakeportal/faces/cs00067.jpg similarity index 100% rename from tests/fakeportal/faces/cs00067.jpg rename to scotests/fakeportal/faces/cs00067.jpg diff --git a/tests/fakeportal/faces/cs00068.jpg b/scotests/fakeportal/faces/cs00068.jpg similarity index 100% rename from tests/fakeportal/faces/cs00068.jpg rename to scotests/fakeportal/faces/cs00068.jpg diff --git a/tests/fakeportal/faces/cs00069.jpg b/scotests/fakeportal/faces/cs00069.jpg similarity index 100% rename from tests/fakeportal/faces/cs00069.jpg rename to scotests/fakeportal/faces/cs00069.jpg diff --git a/tests/fakeportal/faces/cs00070.jpg b/scotests/fakeportal/faces/cs00070.jpg similarity index 100% rename from tests/fakeportal/faces/cs00070.jpg rename to scotests/fakeportal/faces/cs00070.jpg diff --git a/tests/fakeportal/faces/cs00071.jpg b/scotests/fakeportal/faces/cs00071.jpg similarity index 100% rename from tests/fakeportal/faces/cs00071.jpg rename to scotests/fakeportal/faces/cs00071.jpg diff --git a/tests/fakeportal/faces/cs00072.jpg b/scotests/fakeportal/faces/cs00072.jpg similarity index 100% rename from tests/fakeportal/faces/cs00072.jpg rename to scotests/fakeportal/faces/cs00072.jpg diff --git a/tests/fakeportal/faces/cs00073.jpg b/scotests/fakeportal/faces/cs00073.jpg similarity index 100% rename from tests/fakeportal/faces/cs00073.jpg rename to scotests/fakeportal/faces/cs00073.jpg diff --git a/tests/fakeportal/faces/cs00074.jpg b/scotests/fakeportal/faces/cs00074.jpg similarity index 100% rename from tests/fakeportal/faces/cs00074.jpg rename to scotests/fakeportal/faces/cs00074.jpg diff --git a/tests/fakeportal/faces/cs00075.jpg b/scotests/fakeportal/faces/cs00075.jpg similarity index 100% rename from tests/fakeportal/faces/cs00075.jpg rename to scotests/fakeportal/faces/cs00075.jpg diff --git a/tests/fakeportal/faces/cs00076.jpg b/scotests/fakeportal/faces/cs00076.jpg similarity index 100% rename from tests/fakeportal/faces/cs00076.jpg rename to scotests/fakeportal/faces/cs00076.jpg diff --git a/tests/fakeportal/faces/cs00077.jpg b/scotests/fakeportal/faces/cs00077.jpg similarity index 100% rename from tests/fakeportal/faces/cs00077.jpg rename to scotests/fakeportal/faces/cs00077.jpg diff --git a/tests/fakeportal/faces/cs00078.jpg b/scotests/fakeportal/faces/cs00078.jpg similarity index 100% rename from tests/fakeportal/faces/cs00078.jpg rename to scotests/fakeportal/faces/cs00078.jpg diff --git a/tests/fakeportal/faces/cs00079.jpg b/scotests/fakeportal/faces/cs00079.jpg similarity index 100% rename from tests/fakeportal/faces/cs00079.jpg rename to scotests/fakeportal/faces/cs00079.jpg diff --git a/tests/fakeportal/faces/cs00080.jpg b/scotests/fakeportal/faces/cs00080.jpg similarity index 100% rename from tests/fakeportal/faces/cs00080.jpg rename to scotests/fakeportal/faces/cs00080.jpg diff --git a/tests/fakeportal/faces/cs00081.jpg b/scotests/fakeportal/faces/cs00081.jpg similarity index 100% rename from tests/fakeportal/faces/cs00081.jpg rename to scotests/fakeportal/faces/cs00081.jpg diff --git a/tests/fakeportal/faces/cs00082.jpg b/scotests/fakeportal/faces/cs00082.jpg similarity index 100% rename from tests/fakeportal/faces/cs00082.jpg rename to scotests/fakeportal/faces/cs00082.jpg diff --git a/tests/fakeportal/faces/cs00083.jpg b/scotests/fakeportal/faces/cs00083.jpg similarity index 100% rename from tests/fakeportal/faces/cs00083.jpg rename to scotests/fakeportal/faces/cs00083.jpg diff --git a/tests/fakeportal/faces/cs00084.jpg b/scotests/fakeportal/faces/cs00084.jpg similarity index 100% rename from tests/fakeportal/faces/cs00084.jpg rename to scotests/fakeportal/faces/cs00084.jpg diff --git a/tests/fakeportal/faces/cs00085.jpg b/scotests/fakeportal/faces/cs00085.jpg similarity index 100% rename from tests/fakeportal/faces/cs00085.jpg rename to scotests/fakeportal/faces/cs00085.jpg diff --git a/tests/fakeportal/faces/cs00086.jpg b/scotests/fakeportal/faces/cs00086.jpg similarity index 100% rename from tests/fakeportal/faces/cs00086.jpg rename to scotests/fakeportal/faces/cs00086.jpg diff --git a/tests/fakeportal/faces/cs00087.jpg b/scotests/fakeportal/faces/cs00087.jpg similarity index 100% rename from tests/fakeportal/faces/cs00087.jpg rename to scotests/fakeportal/faces/cs00087.jpg diff --git a/tests/fakeportal/faces/cs00088.jpg b/scotests/fakeportal/faces/cs00088.jpg similarity index 100% rename from tests/fakeportal/faces/cs00088.jpg rename to scotests/fakeportal/faces/cs00088.jpg diff --git a/tests/fakeportal/faces/cs00089.jpg b/scotests/fakeportal/faces/cs00089.jpg similarity index 100% rename from tests/fakeportal/faces/cs00089.jpg rename to scotests/fakeportal/faces/cs00089.jpg diff --git a/tests/fakeportal/faces/cs00090.jpg b/scotests/fakeportal/faces/cs00090.jpg similarity index 100% rename from tests/fakeportal/faces/cs00090.jpg rename to scotests/fakeportal/faces/cs00090.jpg diff --git a/tests/fakeportal/faces/cs00091.jpg b/scotests/fakeportal/faces/cs00091.jpg similarity index 100% rename from tests/fakeportal/faces/cs00091.jpg rename to scotests/fakeportal/faces/cs00091.jpg diff --git a/tests/fakeportal/faces/cs00092.jpg b/scotests/fakeportal/faces/cs00092.jpg similarity index 100% rename from tests/fakeportal/faces/cs00092.jpg rename to scotests/fakeportal/faces/cs00092.jpg diff --git a/tests/fakeportal/faces/cs00093.jpg b/scotests/fakeportal/faces/cs00093.jpg similarity index 100% rename from tests/fakeportal/faces/cs00093.jpg rename to scotests/fakeportal/faces/cs00093.jpg diff --git a/tests/fakeportal/faces/cs00094.jpg b/scotests/fakeportal/faces/cs00094.jpg similarity index 100% rename from tests/fakeportal/faces/cs00094.jpg rename to scotests/fakeportal/faces/cs00094.jpg diff --git a/tests/fakeportal/faces/cs00095.jpg b/scotests/fakeportal/faces/cs00095.jpg similarity index 100% rename from tests/fakeportal/faces/cs00095.jpg rename to scotests/fakeportal/faces/cs00095.jpg diff --git a/tests/fakeportal/faces/cs00096.jpg b/scotests/fakeportal/faces/cs00096.jpg similarity index 100% rename from tests/fakeportal/faces/cs00096.jpg rename to scotests/fakeportal/faces/cs00096.jpg diff --git a/tests/fakeportal/faces/cs00097.jpg b/scotests/fakeportal/faces/cs00097.jpg similarity index 100% rename from tests/fakeportal/faces/cs00097.jpg rename to scotests/fakeportal/faces/cs00097.jpg diff --git a/tests/fakeportal/faces/cs00098.jpg b/scotests/fakeportal/faces/cs00098.jpg similarity index 100% rename from tests/fakeportal/faces/cs00098.jpg rename to scotests/fakeportal/faces/cs00098.jpg diff --git a/tests/fakeportal/faces/cs00099.jpg b/scotests/fakeportal/faces/cs00099.jpg similarity index 100% rename from tests/fakeportal/faces/cs00099.jpg rename to scotests/fakeportal/faces/cs00099.jpg diff --git a/tests/fakeportal/fakeportal.py b/scotests/fakeportal/fakeportal.py similarity index 100% rename from tests/fakeportal/fakeportal.py rename to scotests/fakeportal/fakeportal.py diff --git a/scotests/sco_fake_gen.py b/scotests/sco_fake_gen.py new file mode 100644 index 00000000..d010853b --- /dev/null +++ b/scotests/sco_fake_gen.py @@ -0,0 +1,142 @@ +# -*- mode: python -*- +# -*- coding: utf-8 -*- + +"""Creation environnement pour test. +A utiliser avec debug.py (côté serveur). +""" + +from __future__ import print_function +import sys +import string +import pprint +import random + +random.seed(12345) # tests reproductibles + +from debug import REQUEST + +import sco_utils +from sco_exceptions import ScoValueError +import scolars +import sco_formsemestre_inscriptions +import sco_synchro_etuds +import sco_edit_formation +import sco_codes_parcours +from notes_log import log + +DEMODIR = sco_utils.SCO_SRCDIR + "/scotests/demo/" +NOMS = [x.strip() for x in open(DEMODIR + "/noms.txt").readlines()] +PRENOMS_H = [x.strip() for x in open(DEMODIR + "/prenoms-h.txt").readlines()] +PRENOMS_F = [x.strip() for x in open(DEMODIR + "/prenoms-f.txt").readlines()] +# nb: en python2, les chaines ci-dessus sont en utf8 + + +def id_generator(size=6, chars=string.ascii_uppercase + string.digits): + return "".join(random.choice(chars) for _ in range(size)) + + +class ScoFake: + def __init__(self, context, verbose=True): + self.context = context + self.verbose = verbose + + def log(self, msg): + if self.verbose: + print("ScoFake: " + str(msg), file=sys.stderr) + sys.stderr.flush() + log("ScoFake: " + str(msg)) + + def sexenomprenom(self): + """un nom et un prenom au hasard, + toujours en majuscules. + """ + sexe = random.choice(("M", "F")) + if "e" in sexe.lower() or "f" in sexe.lower(): + prenom = random.choice(PRENOMS_F) + else: + prenom = random.choice(PRENOMS_H) + return sexe, random.choice(NOMS).upper(), prenom.upper() + + def create_etud( + self, + cnx=None, + code_nip="", + nom="", + prenom="", + code_ine="", + sexe="", + etape="TST1", + email="test@localhost", + emailperso="perso@localhost", + date_naissance="01/01/2001", + lieu_naissance="Paris", + dept_naissance="75", + domicile="1, rue du test", + codepostaldomicile="75123", + villedomicile="TestCity", + paysdomicile="France", + telephone="0102030405", + typeadresse="domicile", + boursier=None, + description="etudiant test", + ): + """Crée un étudiant""" + if not cnx: + cnx = self.context.GetDBConnexion() + if code_nip == "": + code_nip = str(random.randint(10000, 99999)) + if not sexe or not nom or not prenom: + r_sexe, r_nom, r_prenom = self.sexenomprenom() + if not sexe: + sexe = r_sexe + if not nom: + nom = r_nom + if not prenom: + prenom = r_prenom + etud = scolars.create_etud(self.context, cnx, args=locals(), REQUEST=REQUEST) + pprint.pprint(etud) + self.log("create_etud( %s %s %s ) -> %s" % (sexe, prenom, nom, etud["etudid"])) + inscription = "2020" + sco_synchro_etuds.do_import_etud_admission( + self.context, cnx, etud["etudid"], locals() + ) + return etud + + def create_formation( + self, + acronyme="test", + titre="Formation test", + titre_officiel="Le titre officiel de la formation test", + type_parcours=sco_codes_parcours.ParcoursDUT.TYPE_PARCOURS, + formation_code=None, + code_specialite=None, + ): + """Crée une formation""" + if acronyme == "": + acronyme = "TEST" + str(random.randint(100000, 999999)) + formation_id = self.context.do_formation_create(locals(), REQUEST=REQUEST) + Flist = self.context.formation_list(args={"formation_id": formation_id}) + if not Flist: + raise ScoValueError("formation inexistante !") + self.log( + "create_formation( %s %s ) -> %s" + % (acronyme, titre, Flist[0]["formation_id"]) + ) + return Flist[0] + + def create_ue(self): + pass + + def create_fake_sem(self): + pass + + def test_inscrit_etudiant(self, sem, etud): + sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules( + self.context, + sem["formsemestre_id"], + etud["etudid"], + etat="I", + etape=etud["etape"], + REQUEST=REQUEST, + method="test_inscrit_etudiant", + ) diff --git a/scotests/scointeractive.sh b/scotests/scointeractive.sh new file mode 100755 index 00000000..ef39b102 --- /dev/null +++ b/scotests/scointeractive.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Lancement d'un python scodoc interactif +# dans l'environnement d'un département +# et avec chargement des scripts indiqués +# via from ... import * +# +# Si -r est utilisé, veiller à créer au préalable +# le département via l'interface web (Zope) + +usage() { + echo "Usage: $0 [-r] dept [script...]" + echo "Lance un environnement interactif python/ScoDoc" + echo " -r: supprime et recrée le département (attention: efface la base !)" + exit 1 +} + +set -euo pipefail +cd /opt/scodoc/Products/ScoDoc || exit 2 +source config/utils.sh + +if [ $# -lt 1 ] +then + usage +fi + +if [ "$1" = "-r" ] +then + shift + recreate_dept=1 +fi + + +DEPT="$1" +shift + +if [ "$recreate_dept" = 1 ] +then + (cd config || terminate "no config directory"; ./delete_dept.sh -n "$DEPT") || terminate "error deleting dept $DEPT" + (cd config || terminate "no config directory"; ./create_dept.sh -n "$DEPT") || terminate "error creating dept $DEPT" + systemctl start scodoc +fi + +cmd="from __future__ import print_function;from Zope2 import configure;configure('/opt/scodoc/etc/zope.conf');import Zope2; app=Zope2.app();from debug import *;context = go_dept(app, '""$DEPT""');" + +for f in "$@" +do + cmd="${cmd}exec(open(\"${f}\").read());" +done + +/opt/zope213/bin/python -i -c "$cmd" + + diff --git a/tests/splinter/README.md b/scotests/splinter/README.md similarity index 100% rename from tests/splinter/README.md rename to scotests/splinter/README.md diff --git a/tests/splinter/common.py b/scotests/splinter/common.py similarity index 100% rename from tests/splinter/common.py rename to scotests/splinter/common.py diff --git a/tests/splinter/conn_info.py b/scotests/splinter/conn_info.py similarity index 100% rename from tests/splinter/conn_info.py rename to scotests/splinter/conn_info.py diff --git a/tests/splinter/test-0.py b/scotests/splinter/test-0.py similarity index 100% rename from tests/splinter/test-0.py rename to scotests/splinter/test-0.py diff --git a/tests/splinter/test-intensive-changes.py b/scotests/splinter/test-intensive-changes.py similarity index 100% rename from tests/splinter/test-intensive-changes.py rename to scotests/splinter/test-intensive-changes.py diff --git a/tests/splinter/test-jury.py b/scotests/splinter/test-jury.py similarity index 100% rename from tests/splinter/test-jury.py rename to scotests/splinter/test-jury.py diff --git a/tests/test-all-moys.py b/scotests/test-all-moys.py similarity index 57% rename from tests/test-all-moys.py rename to scotests/test-all-moys.py index 50bfddc9..e9da8d87 100644 --- a/tests/test-all-moys.py +++ b/scotests/test-all-moys.py @@ -2,44 +2,42 @@ # -*- coding: utf-8 -*- """ -Enregistre les moyennes générales de tous les étudinats de tous les +Enregistre les moyennes générales de tous les étudiants de tous les semestres. A utiliser avec debug.py (côté serveur). """ from __future__ import print_function -from debug import * +from debug import go_dept import time -DeptName = 'CJ' +DeptName = "CJ" context = go_dept(app, DeptName) sems = context.Notes.formsemestre_list() -print( '%d semestres' % len(sems) ) +print("%d semestres" % len(sems)) -L=[] -n=0 +L = [] +n = 0 for sem in sems: - formsemestre_id = sem['formsemestre_id'] + formsemestre_id = sem["formsemestre_id"] nt = context.Notes._getNotesCache().get_NotesTable(context.Notes, formsemestre_id) etudids = nt.get_etudids() - use_ue_coef = context.get_preference( 'use_ue_coefs', formsemestre_id ) + use_ue_coef = context.get_preference("use_ue_coefs", formsemestre_id) n += 1 print("%d %s (%d) use_ue_coef=%s" % (n, formsemestre_id, len(etudids), use_ue_coef)) for etudid in etudids: mg = nt.get_etud_moy_gen(etudid) - L.append( (formsemestre_id, str(use_ue_coef), etudid, str(mg)) ) + L.append((formsemestre_id, str(use_ue_coef), etudid, str(mg))) print("Done: %s moys computed" % len(L)) -filename='/opt/tests/%s-%s' % (DeptName, time.strftime('%Y-%m-%dT%H:%M:%S')) +filename = "/opt/tests/%s-%s" % (DeptName, time.strftime("%Y-%m-%dT%H:%M:%S")) print("Writing file '%s'..." % filename) -f = open(filename, 'w') +f = open(filename, "w") for l in L: - f.write('\t'.join(l) + '\n') + f.write("\t".join(l) + "\n") f.close() - - diff --git a/tests/test-apo-csv.py b/scotests/test-apo-csv.py similarity index 100% rename from tests/test-apo-csv.py rename to scotests/test-apo-csv.py diff --git a/tests/test-apo-export-impairs.py b/scotests/test-apo-export-impairs.py similarity index 100% rename from tests/test-apo-export-impairs.py rename to scotests/test-apo-export-impairs.py diff --git a/scotests/test_basic.py b/scotests/test_basic.py new file mode 100644 index 00000000..4fb5b28e --- /dev/null +++ b/scotests/test_basic.py @@ -0,0 +1,17 @@ +# -*- mode: python -*- +# -*- coding: utf-8 -*- + +"""test de base de ScoDoc + +Creation etudiant, formation, semestre, inscription etudiant, creation evaluation, saisie note + +Utiliser comme: + scotests/scointeractive.sh -r TEST00 scotests/test_basic.py + +""" +import scotests.sco_fake_gen as sco_fake_gen + +G = sco_fake_gen.ScoFake(context.Notes) # pylint: disable=undefined-variable + +etud = G.create_etud(code_nip=None) +F = G.create_formation(acronyme="") diff --git a/tests/testpyexcelerator.py b/scotests/testpyexcelerator.py similarity index 100% rename from tests/testpyexcelerator.py rename to scotests/testpyexcelerator.py