From 49af4658196e739cc4e22b91abb0f63d1a269b06 Mon Sep 17 00:00:00 2001 From: Christian Caremoli <> Date: Mon, 29 May 2006 07:08:02 +0000 Subject: [PATCH] CCAR: ajout tests IHM "automatiques" --- Tests/testelem/azv6.comm | 108 ++++++++++ Tests/testelem/testaz76.py | 399 +++++++++++++++++++++++++++++++++++ Tests/testelem/testzzz6az.py | 399 +++++++++++++++++++++++++++++++++++ Tests/testihm/common.py | 201 ++++++++++++++++++ Tests/testihm/testihm1.py | 336 +++++++++++++++++++++++++++++ Tests/testihm/testihm2.py | 73 +++++++ Tests/testihm/testihm3.py | 96 +++++++++ Tests/testihm/testihm4.py | 58 +++++ 8 files changed, 1670 insertions(+) create mode 100644 Tests/testelem/azv6.comm create mode 100644 Tests/testelem/testaz76.py create mode 100644 Tests/testelem/testzzz6az.py create mode 100644 Tests/testihm/common.py create mode 100644 Tests/testihm/testihm1.py create mode 100644 Tests/testihm/testihm2.py create mode 100644 Tests/testihm/testihm3.py create mode 100644 Tests/testihm/testihm4.py diff --git a/Tests/testelem/azv6.comm b/Tests/testelem/azv6.comm new file mode 100644 index 00000000..d921c403 --- /dev/null +++ b/Tests/testelem/azv6.comm @@ -0,0 +1,108 @@ + + +DEBUT(); +P1 = 9.8; + +P2 = 8.8; + +P3 = 7; + +P5 = (P3 * P1); + +P6 = (P1 - 3); + +P4 = [2, 3, 4]; + +#Pas trouve shellpanel + +MAILLA2=LIRE_MAILLAGE(UNITE=P4[1],); + +aaa = FORMULE(REEL='(a+z) = (a,z)',); + +MAIL=LIRE_MAILLAGE(UNITE=P3,); +# 'LIRE_MAILLAGE', 'UNITE' --> uniquebasepanel + +az = FORMULE(REEL='(aaaaa) = (ae,inst)',); + +AFFE1=AFFE_MODELE(MAILLAGE=MAIL, + AFFE=(_F(GROUP_MA=('RESSORT','eee',), + PHENOMENE='MECANIQUE', + MODELISATION='DIS_T',), + _F(GROUP_MA='MASSES', + PHENOMENE='MECANIQUE', + MODELISATION='DIS_T',), + _F(GROUP_NO=('GNP3','GNP5','GNP6','GNP7','GNP8','GNP9','GNP10','GNP11','GNP12',), + PHENOMENE='ACOUSTIQUE', + MODELISATION='PLAN',),),); + +MOD=AFFE_MODELE(MAILLAGE=MAIL, + AFFE=(_F(GROUP_MA='RESSORT', + PHENOMENE='MECANIQUE', + MODELISATION='DIS_T',), + _F(GROUP_MA='MASSES', + PHENOMENE='MECANIQUE', + MODELISATION='DIS_T',), + _F(TOUT='OUI', + PHENOMENE='THERMIQUE', + MODELISATION='COQUE',),),); + +CARA=AFFE_CARA_ELEM(MODELE=MOD, + POUTRE=_F(GROUP_MA='MA', + SECTION='CERCLE', + CARA='R', + VALE=(3.0,P6,),),); +# 'AFFE_MODELE', 'MAILLAGE' --> uniqueassdpanel +# AFFE_MODELE', 'AFFE', 'GROUP_MA' --> plusieursbasepanel +# 'AFFE_MODELE', 'AFFE', 'PHENOMENE' --> uniqueintopanel +# 'AFFE_MODELE', 'AFFE', 'b_mecanique'--> plusieursintopanel + +F1=DEFI_FONCTION(NOM_PARA='DX', + VALE=(5.0,3.0, +P4[1],P3, +),); + +F3=DEFI_FONCTION(NOM_PARA='DRX', + VALE_C=(5.0,7.0,9.0, +9.0,8.0,7.0, +),); +# 'DEFI_FONCTION', 'VALE' --> fonctionpanel + +MATER2=DEFI_MATERIAU(ELAS=_F(E=100000000000.0, + NU=0.0,), + ECRO_ASYM_LINE=_F(DC_SIGM_EPSI=0.0, + SY_C=200000000.0, + DT_SIGM_EPSI=0.0, + SY_T=50000000.0,),); + +PS1=DEFI_PARA_SENSI(VALE=1.0,); + +PS2=DEFI_PARA_SENSI(VALE=1.0,); + +PS3=DEFI_PARA_SENSI(VALE=1.0,); + +CHMAT2=AFFE_MATERIAU(MAILLAGE=MAIL, + AFFE=_F(TOUT='OUI', + MATER=MATER2,),); + +AAAZ=AFFE_CHAR_THER(MODELE=AFFE1, + TEMP_IMPO=_F(TOUT='OUI', + TEMP=0.0,),); + +TH1=THER_LINEAIRE(MODELE=AFFE1, + CHAM_MATER=CHMAT2, + EXCIT=_F(CHARGE=AAAZ,), + SENSIBILITE=(PS1,PS2,),); +# 'THER_LINEAIRE', 'SENSIBILITE' --> plusieursassdpanel + +ACA1=AFFE_CHAR_ACOU(MODELE=AFFE1, + PRES_IMPO=_F(TOUT='OUI', + PRES=('RI',3.0,3.0,),),); +# 'AFFE_CHAR_ACOU', 'PRES_IMPO', 'PRES' --> uniquecomppanel + +MACRO_MATR_ASSE(MODELE=AFFE1, + NUME_DDL=CO('DDL1'), + MATR_ASSE=_F(MATRICE=CO('MAT1'), + OPTION='RIGI_THER',),); +# 'MACRO_MATR_ASSE', 'MATR_ASSE', 'MATRICE' --> uniquesdcopanel + +FIN(); diff --git a/Tests/testelem/testaz76.py b/Tests/testelem/testaz76.py new file mode 100644 index 00000000..2dd8a129 --- /dev/null +++ b/Tests/testelem/testaz76.py @@ -0,0 +1,399 @@ +# coding=utf-8 + +import os +import unittest +import difflib +import compare + +import prefs +from Editeur import appli + +def add_param(j,pos,nom,valeur): + co=j.addentite("PARAMETRE",pos) + co.set_nom(nom) + co.set_valeur(valeur) + return co + +def add_mcsimp(obj,nom,valeur): + mcs=obj.get_child(nom,restreint='oui') + if mcs is None: + pos=obj.get_index_child(nom) + mcs=obj.addentite(nom,pos) + mcs.set_valeur(mcs.eval_val(valeur)) + return mcs + +def cdiff(text1,text2): + return " ".join(difflib.context_diff(text1.splitlines(1),text2.splitlines(1))) + +class TestCase(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + CONTEXT.unset_current_step() + + def test000(self): + """ Test de construction du fichier de commandes az.comm de zero""" + + app=appli.STANDALONE(version='v7.6') + j=app.newJDC() +# commande DEBUT + co=j.addentite("DEBUT",0) +# commande FIN + co=j.addentite("FIN",1) +# parametres + pos=0 + pos=pos+1 + co=add_param(j,pos,"P1","9.8") + pos=pos+1 + co=add_param(j,pos,"P2","8.8") + pos=pos+1 + co=add_param(j,pos,"P3","7") + pos=pos+1 + co=add_param(j,pos,"P5","P3*P1") + pos=pos+1 + co=add_param(j,pos,"P6","P1-3") + pos=pos+1 + co=add_param(j,pos,"P4","[2,3,4]") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur("Pas trouve shellpanel") +# commande LIRE_MAILLAGE + pos=pos+1 + co=j.addentite("LIRE_MAILLAGE",pos) + test,mess=co.nomme_sd("MAILLA2") + mcs=co.addentite("UNITE") + valeur=mcs.eval_val("P4[1]") + test=mcs.set_valeur(valeur) +# formule + pos=pos+1 + co=j.addentite("FORMULE",pos) + co.update_formule_python(("aaa","REEL","a+z","(a,z)")) +# commande LIRE_MAILLAGE + pos=pos+1 + ma=co=j.addentite("LIRE_MAILLAGE",pos) + test,mess=co.nomme_sd("MAIL") + mcs=co.addentite("UNITE") + valeur,validite=mcs.eval_valeur("P3") + test=mcs.set_valeur(valeur) +# + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'LIRE_MAILLAGE', 'UNITE' --> uniquebasepanel") +# formule + pos=pos+1 + co=j.addentite("FORMULE",pos) + co.update_formule_python(("az","REEL","aaaaa","(ae,inst)")) +# commande AFFE_MODELE + pos=pos+1 + co=j.addentite("AFFE_MODELE",pos) + mcs=co.get_child("MAILLAGE") + valeur,validite=mcs.eval_valeur("MAIL") + assert valeur == ma.sd + test=mcs.set_valeur(valeur) + assert valeur == co["MAILLAGE"] + mcf=co.addentite("AFFE") + mcs=mcf[0].get_child("PHENOMENE") + valeur=mcs.eval_val_item('MECANIQUE') + assert valeur=='MECANIQUE',str(valeur) + test=mcs.set_valeur(valeur) + assert mcf["PHENOMENE"] == 'MECANIQUE' + mcs=mcf[0].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + assert mcf["MODELISATION"] == 'DIS_T' + mcs=add_mcsimp(mcf[0],"GROUP_MA",('RESSORT','eee',)) + + mcf=co.addentite("AFFE") + mcs=mcf[1].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('MECANIQUE')) + mcs=mcf[1].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + mcs=add_mcsimp(mcf[1],"GROUP_MA",'MASSES') + + mcf=co.addentite("AFFE") + mcs=mcf[2].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('ACOUSTIQUE')) + mcs=mcf[2].get_child("b_acoustique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('PLAN')) + #mcs=add_mcsimp(mcf[2],"GROUP_NO",'GNP3,GNP5,GNP6,GNP7,GNP8,GNP9,GNP10,GNP11,GNP12') + mcs=add_mcsimp(mcf[2],"GROUP_NO","'GNP3','GNP5','GNP6','GNP7','GNP8','GNP9','GNP10','GNP11','GNP12'") + + co.nomme_sd("AFFE1") +# commande AFFE_MODELE + pos=pos+1 + co=j.addentite("AFFE_MODELE",pos) + mcs=co.get_child("MAILLAGE") + mcs.set_valeur(mcs.eval_val("MAIL")) + + mcf=co.addentite("AFFE") + mcs=mcf[0].get_child("PHENOMENE") + valeur=mcs.eval_val_item('MECANIQUE') + test=mcs.set_valeur(valeur) + mcs=mcf[0].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + mcs=add_mcsimp(mcf[0],"GROUP_MA",'RESSORT') + + mcf=co.addentite("AFFE") + mcs=mcf[1].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('MECANIQUE')) + mcs=mcf[1].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + mcs=add_mcsimp(mcf[1],"GROUP_MA",'MASSES') + + mcf=co.addentite("AFFE") + mcs=mcf[2].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('THERMIQUE')) + mcs=mcf[2].get_child("b_thermique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('COQUE')) + mcs=add_mcsimp(mcf[2],"TOUT",'OUI') + + co.nomme_sd("MOD") +#CARA=AFFE_CARA_ELEM(MODELE=MOD, +# POUTRE=_F(GROUP_MA='MA', +# SECTION='CERCLE', +# CARA='R', +# VALE=(3.0,P6,),),); + pos=pos+1 + co=j.addentite("AFFE_CARA_ELEM",pos) + mcs=co.get_child("MODELE") + mcs.set_valeur(mcs.eval_val("MOD")) + mcf=co.addentite("POUTRE") + mcs=mcf[0].get_child("SECTION") + mcs.set_valeur(mcs.eval_val('CERCLE')) + assert mcf[0]["SECTION"] == 'CERCLE' + mcs=add_mcsimp(mcf[0],"GROUP_MA",'MA') + mcs=mcf[0].get_child("b_cercle").get_child("b_constant").get_child("CARA") + mcs.set_valeur(mcs.eval_val('R')) + mcs=mcf[0].get_child("b_cercle").get_child("b_constant").get_child("VALE") + mcs.set_valeur(mcs.eval_val('3.0,P6')) + co.nomme_sd("CARA") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + text=""" 'AFFE_MODELE', 'MAILLAGE' --> uniqueassdpanel + AFFE_MODELE', 'AFFE', 'GROUP_MA' --> plusieursbasepanel + 'AFFE_MODELE', 'AFFE', 'PHENOMENE' --> uniqueintopanel + 'AFFE_MODELE', 'AFFE', 'b_mecanique'--> plusieursintopanel""" + co.set_valeur(text) +#F1=DEFI_FONCTION(NOM_PARA='DX', +# VALE=(5.0,3.0,P4[1],P3,),); + pos=pos+1 + co=j.addentite("DEFI_FONCTION",pos) + mcs=co.get_child("NOM_PARA") + mcs.set_valeur(mcs.eval_val("DX")) + mcs=co.addentite("VALE") + mcs.set_valeur(mcs.eval_val("5.0,3.0,P4[1],P3")) + co.nomme_sd("F1") +#F3=DEFI_FONCTION(NOM_PARA='DRX', +# VALE_C=(5.0,7.0,9.0,9.0,8.0,7.0,),); + pos=pos+1 + co=j.addentite("DEFI_FONCTION",pos) + mcs=co.get_child("NOM_PARA") + mcs.set_valeur(mcs.eval_val("DRX")) + mcs=co.addentite("VALE_C") + mcs.set_valeur(mcs.eval_val("5.0,7.0,9.0,9.0,8.0,7.0")) + co.nomme_sd("F3") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'DEFI_FONCTION', 'VALE' --> fonctionpanel ") +#MATER2=DEFI_MATERIAU(ELAS=_F(E=100000000000.0, +# NU=0.0,), +# ECRO_ASYM_LINE=_F(DC_SIGM_EPSI=0.0, +# SY_C=200000000.0, +# DT_SIGM_EPSI=0.0, +# SY_T=50000000.0,),); + pos=pos+1 + co=j.addentite("DEFI_MATERIAU",pos) + mcf=co.addentite("ELAS") + mcs=mcf[0].get_child("E") + mcs.set_valeur(mcs.eval_val("100000000000.0")) + mcs=mcf[0].get_child("NU") + mcs.set_valeur(mcs.eval_val("0.0")) + mcf=co.addentite("ECRO_ASYM_LINE") + mcs=mcf[0].get_child("DC_SIGM_EPSI") + mcs.set_valeur(mcs.eval_val("0.0")) + mcs=mcf[0].get_child("DT_SIGM_EPSI") + mcs.set_valeur(mcs.eval_val("0.0")) + mcs=mcf[0].get_child("SY_C") + mcs.set_valeur(mcs.eval_val("200000000.0")) + mcs=mcf[0].get_child("SY_T") + mcs.set_valeur(mcs.eval_val("50000000.0")) + co.nomme_sd("MATER2") +#PS1=DEFI_PARA_SENSI(VALE=1.0,); +#PS2=DEFI_PARA_SENSI(VALE=1.0,); +#PS3=DEFI_PARA_SENSI(VALE=1.0,); + pos=pos+1 + co=j.addentite("DEFI_PARA_SENSI",pos) + mcs=co.get_child("VALE") + mcs.set_valeur(mcs.eval_val("1.0")) + co.nomme_sd("PS1") + pos=pos+1 + co=j.addentite("DEFI_PARA_SENSI",pos) + mcs=co.get_child("VALE") + mcs.set_valeur(mcs.eval_val("1.0")) + co.nomme_sd("PS2") + pos=pos+1 + co=j.addentite("DEFI_PARA_SENSI",pos) + mcs=co.get_child("VALE") + mcs.set_valeur(mcs.eval_val("1.0")) + co.nomme_sd("PS3") +#CHMAT2=AFFE_MATERIAU(MAILLAGE=MAIL, +# AFFE=_F(TOUT='OUI', +# MATER=MATER2,),); + pos=pos+1 + co=j.addentite("AFFE_MATERIAU",pos) + add_mcsimp(co,"MAILLAGE","MAIL") + mcf=co.get_child("AFFE") + add_mcsimp(mcf[0],"TOUT","OUI") + add_mcsimp(mcf[0],"MATER","MATER2") + co.nomme_sd("CHMAT2") +#AAAZ=AFFE_CHAR_THER(MODELE=AFFE1, +# TEMP_IMPO=_F(TOUT='OUI', +# TEMP=0.0,),); + pos=pos+1 + co=j.addentite("AFFE_CHAR_THER",pos) + add_mcsimp(co,"MODELE","AFFE1") + mcf=co.addentite("TEMP_IMPO") + add_mcsimp(mcf[0],"TOUT","OUI") + add_mcsimp(mcf[0],"TEMP","0.0") + co.nomme_sd("AAAZ") +#TH1=THER_LINEAIRE(MODELE=AFFE1, +# CHAM_MATER=CHMAT2, +# EXCIT=_F(CHARGE=AAAZ,), +# SENSIBILITE=(PS1,PS2,),); + pos=pos+1 + co=j.addentite("THER_LINEAIRE",pos) + add_mcsimp(co,"MODELE","AFFE1") + add_mcsimp(co,"CHAM_MATER","CHMAT2") + mcf=co.get_child("EXCIT") + add_mcsimp(mcf[0],"CHARGE","AAAZ") + add_mcsimp(co,"SENSIBILITE","PS1,PS2") + co.nomme_sd("TH1") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'THER_LINEAIRE', 'SENSIBILITE' --> plusieursassdpanel") +#ACA1=AFFE_CHAR_ACOU(MODELE=AFFE1, +# PRES_IMPO=_F(TOUT='OUI', +# PRES=('RI',3.0,3.0,),),); + pos=pos+1 + co=j.addentite("AFFE_CHAR_ACOU",pos) + add_mcsimp(co,"MODELE","AFFE1") + mcf=co.addentite("PRES_IMPO") + add_mcsimp(mcf[0],"TOUT","OUI") + add_mcsimp(mcf[0],"PRES","'RI',3.0,3.0") + co.nomme_sd("ACA1") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'AFFE_CHAR_ACOU', 'PRES_IMPO', 'PRES' --> uniquecomppanel") + +# 'AFFE_CHAR_ACOU', 'PRES_IMPO', 'PRES' --> uniquecomppanel + +#MACRO_MATR_ASSE(MODELE=AFFE1, +# NUME_DDL=CO('DDL1'), +# MATR_ASSE=_F(MATRICE=CO('MAT1'), +# OPTION='RIGI_THER',),); + pos=pos+1 + co=j.addentite("MACRO_MATR_ASSE",pos) + add_mcsimp(co,"MODELE","AFFE1") + mcs=co.get_child("NUME_DDL") + mcs.set_valeur_co('DDL1') + mcf=co.get_child("MATR_ASSE") + add_mcsimp(mcf[0],"OPTION","RIGI_THER") + mcs=mcf[0].get_child("MATRICE") + mcs.set_valeur_co('MAT1') +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'MACRO_MATR_ASSE', 'MATR_ASSE', 'MATRICE' --> uniquesdcopanel") + + assert j.isvalid(),j.report() + + text1=app.get_text_JDC(j,'python') + file=os.path.join(prefs.INSTALLDIR,"Tests/testelem/az.comm") + f=open(file) + text2=f.read() + f.close() + assert text1 == text2 , cdiff(text1,text2) + + def test001(self): + """ Test de construction d'un fichier de commandes avec DEFI_LIST_REEL, fonction et parametre de zero""" + + app=appli.STANDALONE(version='v7.6') + j=app.newJDC() +# commande DEBUT + co=j.addentite("DEBUT",0) +# commande FIN + co=j.addentite("FIN",1) +#parametre + pos=0 + pos=pos+1 + co=add_param(j,pos,"P1","9.8") + pos=pos+1 + co=add_param(j,pos,"P2","sin(P1)") +# formule + pos=pos+1 + co=j.addentite("FORMULE",pos) + co.update_formule_python(("aaa","REEL","a+z","(a,z)")) +#parametre de formule + pos=pos+1 + co=add_param(j,pos,"P3","aaa(P1,2.)") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","1.,2.,3.") + co.nomme_sd("LI1") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","sin(1.)") + co.nomme_sd("LI2") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","aaa(1.,2.)") + co.nomme_sd("LI3") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","sin(1.,2)") + co.nomme_sd("LI4") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","aaa(1.)") + co.nomme_sd("LI5") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","1,sin(1.),2") + co.nomme_sd("LI6") + + expected="""DEBUT CR validation : SansNom + Etape : DEFI_LIST_REEL ligne : ... + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Concept retourné non défini ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Mot-clé simple : VALE + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! 'sin(1.,2)' n'est pas d'un type autorisé: ('R',) ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Fin Mot-clé simple : VALE + Fin Etape : DEFI_LIST_REEL + Etape : DEFI_LIST_REEL ligne : ... + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Concept retourné non défini ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Mot-clé simple : VALE + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! 'aaa(1.)' n'est pas d'un type autorisé: ('R',) ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Fin Mot-clé simple : VALE + Fin Etape : DEFI_LIST_REEL +FIN CR validation :SansNom +""" + msg=str( j.report()) + assert compare.check(expected,msg),cdiff(expected,msg) diff --git a/Tests/testelem/testzzz6az.py b/Tests/testelem/testzzz6az.py new file mode 100644 index 00000000..d2b519ca --- /dev/null +++ b/Tests/testelem/testzzz6az.py @@ -0,0 +1,399 @@ +# coding=utf-8 + +import os +import unittest +import difflib +import compare + +import prefs +from Editeur import appli + +def add_param(j,pos,nom,valeur): + co=j.addentite("PARAMETRE",pos) + co.set_nom(nom) + co.set_valeur(valeur) + return co + +def add_mcsimp(obj,nom,valeur): + mcs=obj.get_child(nom,restreint='oui') + if mcs is None: + pos=obj.get_index_child(nom) + mcs=obj.addentite(nom,pos) + mcs.set_valeur(mcs.eval_val(valeur)) + return mcs + +def cdiff(text1,text2): + return " ".join(difflib.context_diff(text1.splitlines(1),text2.splitlines(1))) + +class TestCase(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + CONTEXT.unset_current_step() + + def test000(self): + """ Test de construction du fichier de commandes az.comm de zero""" + + app=appli.STANDALONE(version='v6') + j=app.newJDC() +# commande DEBUT + co=j.addentite("DEBUT",0) +# commande FIN + co=j.addentite("FIN",1) +# parametres + pos=0 + pos=pos+1 + co=add_param(j,pos,"P1","9.8") + pos=pos+1 + co=add_param(j,pos,"P2","8.8") + pos=pos+1 + co=add_param(j,pos,"P3","7") + pos=pos+1 + co=add_param(j,pos,"P5","P3*P1") + pos=pos+1 + co=add_param(j,pos,"P6","P1-3") + pos=pos+1 + co=add_param(j,pos,"P4","[2,3,4]") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur("Pas trouve shellpanel") +# commande LIRE_MAILLAGE + pos=pos+1 + co=j.addentite("LIRE_MAILLAGE",pos) + test,mess=co.nomme_sd("MAILLA2") + mcs=co.addentite("UNITE") + valeur=mcs.eval_val("P4[1]") + test=mcs.set_valeur(valeur) +# formule + pos=pos+1 + co=j.addentite("FORMULE",pos) + co.update(("aaa","REEL","a+z","(a,z)")) +# commande LIRE_MAILLAGE + pos=pos+1 + ma=co=j.addentite("LIRE_MAILLAGE",pos) + test,mess=co.nomme_sd("MAIL") + mcs=co.addentite("UNITE") + valeur,validite=mcs.eval_valeur("P3") + test=mcs.set_valeur(valeur) +# + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'LIRE_MAILLAGE', 'UNITE' --> uniquebasepanel") +# formule + pos=pos+1 + co=j.addentite("FORMULE",pos) + co.update(("az","REEL","aaaaa","(ae,inst)")) +# commande AFFE_MODELE + pos=pos+1 + co=j.addentite("AFFE_MODELE",pos) + mcs=co.get_child("MAILLAGE") + valeur,validite=mcs.eval_valeur("MAIL") + assert valeur == ma.sd + test=mcs.set_valeur(valeur) + assert valeur == co["MAILLAGE"] + mcf=co.addentite("AFFE") + mcs=mcf[0].get_child("PHENOMENE") + valeur=mcs.eval_val_item('MECANIQUE') + assert valeur=='MECANIQUE',str(valeur) + test=mcs.set_valeur(valeur) + assert mcf["PHENOMENE"] == 'MECANIQUE' + mcs=mcf[0].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + assert mcf["MODELISATION"] == 'DIS_T' + mcs=add_mcsimp(mcf[0],"GROUP_MA",('RESSORT','eee',)) + + mcf=co.addentite("AFFE") + mcs=mcf[1].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('MECANIQUE')) + mcs=mcf[1].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + mcs=add_mcsimp(mcf[1],"GROUP_MA",'MASSES') + + mcf=co.addentite("AFFE") + mcs=mcf[2].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('ACOUSTIQUE')) + mcs=mcf[2].get_child("b_acoustique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('PLAN')) + #mcs=add_mcsimp(mcf[2],"GROUP_NO",'GNP3,GNP5,GNP6,GNP7,GNP8,GNP9,GNP10,GNP11,GNP12') + mcs=add_mcsimp(mcf[2],"GROUP_NO","'GNP3','GNP5','GNP6','GNP7','GNP8','GNP9','GNP10','GNP11','GNP12'") + + co.nomme_sd("AFFE1") +# commande AFFE_MODELE + pos=pos+1 + co=j.addentite("AFFE_MODELE",pos) + mcs=co.get_child("MAILLAGE") + mcs.set_valeur(mcs.eval_val("MAIL")) + + mcf=co.addentite("AFFE") + mcs=mcf[0].get_child("PHENOMENE") + valeur=mcs.eval_val_item('MECANIQUE') + test=mcs.set_valeur(valeur) + mcs=mcf[0].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + mcs=add_mcsimp(mcf[0],"GROUP_MA",'RESSORT') + + mcf=co.addentite("AFFE") + mcs=mcf[1].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('MECANIQUE')) + mcs=mcf[1].get_child("b_mecanique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('DIS_T')) + mcs=add_mcsimp(mcf[1],"GROUP_MA",'MASSES') + + mcf=co.addentite("AFFE") + mcs=mcf[2].get_child("PHENOMENE") + mcs.set_valeur(mcs.eval_val_item('THERMIQUE')) + mcs=mcf[2].get_child("b_thermique").get_child("MODELISATION") + mcs.set_valeur(mcs.eval_val_item('COQUE')) + mcs=add_mcsimp(mcf[2],"TOUT",'OUI') + + co.nomme_sd("MOD") +#CARA=AFFE_CARA_ELEM(MODELE=MOD, +# POUTRE=_F(GROUP_MA='MA', +# SECTION='CERCLE', +# CARA='R', +# VALE=(3.0,P6,),),); + pos=pos+1 + co=j.addentite("AFFE_CARA_ELEM",pos) + mcs=co.get_child("MODELE") + mcs.set_valeur(mcs.eval_val("MOD")) + mcf=co.addentite("POUTRE") + mcs=mcf[0].get_child("SECTION") + mcs.set_valeur(mcs.eval_val('CERCLE')) + assert mcf[0]["SECTION"] == 'CERCLE' + mcs=add_mcsimp(mcf[0],"GROUP_MA",'MA') + mcs=mcf[0].get_child("b_cercle").get_child("CARA") + mcs.set_valeur(mcs.eval_val('R')) + mcs=mcf[0].get_child("b_cercle").get_child("VALE") + mcs.set_valeur(mcs.eval_val('3.0,P6')) + co.nomme_sd("CARA") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + text=""" 'AFFE_MODELE', 'MAILLAGE' --> uniqueassdpanel + AFFE_MODELE', 'AFFE', 'GROUP_MA' --> plusieursbasepanel + 'AFFE_MODELE', 'AFFE', 'PHENOMENE' --> uniqueintopanel + 'AFFE_MODELE', 'AFFE', 'b_mecanique'--> plusieursintopanel""" + co.set_valeur(text) +#F1=DEFI_FONCTION(NOM_PARA='DX', +# VALE=(5.0,3.0,P4[1],P3,),); + pos=pos+1 + co=j.addentite("DEFI_FONCTION",pos) + mcs=co.get_child("NOM_PARA") + mcs.set_valeur(mcs.eval_val("DX")) + mcs=co.addentite("VALE") + mcs.set_valeur(mcs.eval_val("5.0,3.0,P4[1],P3")) + co.nomme_sd("F1") +#F3=DEFI_FONCTION(NOM_PARA='DRX', +# VALE_C=(5.0,7.0,9.0,9.0,8.0,7.0,),); + pos=pos+1 + co=j.addentite("DEFI_FONCTION",pos) + mcs=co.get_child("NOM_PARA") + mcs.set_valeur(mcs.eval_val("DRX")) + mcs=co.addentite("VALE_C") + mcs.set_valeur(mcs.eval_val("5.0,7.0,9.0,9.0,8.0,7.0")) + co.nomme_sd("F3") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'DEFI_FONCTION', 'VALE' --> fonctionpanel ") +#MATER2=DEFI_MATERIAU(ELAS=_F(E=100000000000.0, +# NU=0.0,), +# ECRO_ASYM_LINE=_F(DC_SIGM_EPSI=0.0, +# SY_C=200000000.0, +# DT_SIGM_EPSI=0.0, +# SY_T=50000000.0,),); + pos=pos+1 + co=j.addentite("DEFI_MATERIAU",pos) + mcf=co.addentite("ELAS") + mcs=mcf[0].get_child("E") + mcs.set_valeur(mcs.eval_val("100000000000.0")) + mcs=mcf[0].get_child("NU") + mcs.set_valeur(mcs.eval_val("0.0")) + mcf=co.addentite("ECRO_ASYM_LINE") + mcs=mcf[0].get_child("DC_SIGM_EPSI") + mcs.set_valeur(mcs.eval_val("0.0")) + mcs=mcf[0].get_child("DT_SIGM_EPSI") + mcs.set_valeur(mcs.eval_val("0.0")) + mcs=mcf[0].get_child("SY_C") + mcs.set_valeur(mcs.eval_val("200000000.0")) + mcs=mcf[0].get_child("SY_T") + mcs.set_valeur(mcs.eval_val("50000000.0")) + co.nomme_sd("MATER2") +#PS1=DEFI_PARA_SENSI(VALE=1.0,); +#PS2=DEFI_PARA_SENSI(VALE=1.0,); +#PS3=DEFI_PARA_SENSI(VALE=1.0,); + pos=pos+1 + co=j.addentite("DEFI_PARA_SENSI",pos) + mcs=co.get_child("VALE") + mcs.set_valeur(mcs.eval_val("1.0")) + co.nomme_sd("PS1") + pos=pos+1 + co=j.addentite("DEFI_PARA_SENSI",pos) + mcs=co.get_child("VALE") + mcs.set_valeur(mcs.eval_val("1.0")) + co.nomme_sd("PS2") + pos=pos+1 + co=j.addentite("DEFI_PARA_SENSI",pos) + mcs=co.get_child("VALE") + mcs.set_valeur(mcs.eval_val("1.0")) + co.nomme_sd("PS3") +#CHMAT2=AFFE_MATERIAU(MAILLAGE=MAIL, +# AFFE=_F(TOUT='OUI', +# MATER=MATER2,),); + pos=pos+1 + co=j.addentite("AFFE_MATERIAU",pos) + add_mcsimp(co,"MAILLAGE","MAIL") + mcf=co.get_child("AFFE") + add_mcsimp(mcf[0],"TOUT","OUI") + add_mcsimp(mcf[0],"MATER","MATER2") + co.nomme_sd("CHMAT2") +#AAAZ=AFFE_CHAR_THER(MODELE=AFFE1, +# TEMP_IMPO=_F(TOUT='OUI', +# TEMP=0.0,),); + pos=pos+1 + co=j.addentite("AFFE_CHAR_THER",pos) + add_mcsimp(co,"MODELE","AFFE1") + mcf=co.addentite("TEMP_IMPO") + add_mcsimp(mcf[0],"TOUT","OUI") + add_mcsimp(mcf[0],"TEMP","0.0") + co.nomme_sd("AAAZ") +#TH1=THER_LINEAIRE(MODELE=AFFE1, +# CHAM_MATER=CHMAT2, +# EXCIT=_F(CHARGE=AAAZ,), +# SENSIBILITE=(PS1,PS2,),); + pos=pos+1 + co=j.addentite("THER_LINEAIRE",pos) + add_mcsimp(co,"MODELE","AFFE1") + add_mcsimp(co,"CHAM_MATER","CHMAT2") + mcf=co.get_child("EXCIT") + add_mcsimp(mcf[0],"CHARGE","AAAZ") + add_mcsimp(co,"SENSIBILITE","PS1,PS2") + co.nomme_sd("TH1") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'THER_LINEAIRE', 'SENSIBILITE' --> plusieursassdpanel") +#ACA1=AFFE_CHAR_ACOU(MODELE=AFFE1, +# PRES_IMPO=_F(TOUT='OUI', +# PRES=('RI',3.0,3.0,),),); + pos=pos+1 + co=j.addentite("AFFE_CHAR_ACOU",pos) + add_mcsimp(co,"MODELE","AFFE1") + mcf=co.addentite("PRES_IMPO") + add_mcsimp(mcf[0],"TOUT","OUI") + add_mcsimp(mcf[0],"PRES","'RI',3.0,3.0") + co.nomme_sd("ACA1") +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'AFFE_CHAR_ACOU', 'PRES_IMPO', 'PRES' --> uniquecomppanel") + +# 'AFFE_CHAR_ACOU', 'PRES_IMPO', 'PRES' --> uniquecomppanel + +#MACRO_MATR_ASSE(MODELE=AFFE1, +# NUME_DDL=CO('DDL1'), +# MATR_ASSE=_F(MATRICE=CO('MAT1'), +# OPTION='RIGI_THER',),); + pos=pos+1 + co=j.addentite("MACRO_MATR_ASSE",pos) + add_mcsimp(co,"MODELE","AFFE1") + mcs=co.get_child("NUME_DDL") + mcs.set_valeur_co('DDL1') + mcf=co.get_child("MATR_ASSE") + add_mcsimp(mcf[0],"OPTION","RIGI_THER") + mcs=mcf[0].get_child("MATRICE") + mcs.set_valeur_co('MAT1') +# commentaire + pos=pos+1 + co=j.addentite("COMMENTAIRE",pos) + co.set_valeur(" 'MACRO_MATR_ASSE', 'MATR_ASSE', 'MATRICE' --> uniquesdcopanel") + + assert j.isvalid(),j.report() + + text1=app.get_text_JDC(j,'python') + file=os.path.join(prefs.INSTALLDIR,"Tests/testelem/azv6.comm") + f=open(file) + text2=f.read() + f.close() + assert text1 == text2 , cdiff(text1,text2) + + def test001(self): + """ Test de construction d'un fichier de commandes avec DEFI_LIST_REEL, fonction et parametre de zero""" + + app=appli.STANDALONE(version='v6') + j=app.newJDC() +# commande DEBUT + co=j.addentite("DEBUT",0) +# commande FIN + co=j.addentite("FIN",1) +#parametre + pos=0 + pos=pos+1 + co=add_param(j,pos,"P1","9.8") + pos=pos+1 + co=add_param(j,pos,"P2","sin(P1)") +# formule + pos=pos+1 + co=j.addentite("FORMULE",pos) + co.update(("aaa","REEL","a+z","(a,z)")) +#parametre de formule + pos=pos+1 + co=add_param(j,pos,"P3","aaa(P1,2.)") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","1.,2.,3.") + co.nomme_sd("LI1") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","sin(1.)") + co.nomme_sd("LI2") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","aaa(1.,2.)") + co.nomme_sd("LI3") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","sin(1.,2)") + co.nomme_sd("LI4") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","aaa(1.)") + co.nomme_sd("LI5") +#commande defi_list_reel + pos=pos+1 + co=j.addentite("DEFI_LIST_REEL",pos) + add_mcsimp(co,"VALE","1,sin(1.),2") + co.nomme_sd("LI6") + + expected="""DEBUT CR validation : SansNom + Etape : DEFI_LIST_REEL ligne : ... + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Concept retourné non défini ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Mot-clé simple : VALE + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! 'sin(1.,2)' n'est pas d'un type autorisé: ('R',) ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Fin Mot-clé simple : VALE + Fin Etape : DEFI_LIST_REEL + Etape : DEFI_LIST_REEL ligne : ... + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Concept retourné non défini ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Mot-clé simple : VALE + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! 'aaa(1.)' n'est pas d'un type autorisé: ('R',) ! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Fin Mot-clé simple : VALE + Fin Etape : DEFI_LIST_REEL +FIN CR validation :SansNom +""" + msg=str( j.report()) + assert compare.check(expected,msg),cdiff(expected,msg) diff --git a/Tests/testihm/common.py b/Tests/testihm/common.py new file mode 100644 index 00000000..fbd438a2 --- /dev/null +++ b/Tests/testihm/common.py @@ -0,0 +1,201 @@ +# -*- coding: utf-8 -*- + +root=None +jdcdisplay=None + +class UnKnownNode(Exception):pass + +def init_common(r,j): + global root,jdcdisplay + root=r + jdcdisplay=j + +def KP_return(): + root.event_generate("") + root.update() + +def delete_node(panel): + panel.node.delete() + +def uncomment_command(panel): + panel.bouton_unc.invoke() + root.update() + panel=jdcdisplay.panel_courant + return panel + +def comment_command(panel): + panel.nb.selectpage('Commentaire') + panel.comment_commande() + root.update() + panel=jdcdisplay.panel_courant + return panel + +def create_mocle(nom,panel): + panel.nb.selectpage('Mocles') + panel.Liste.afficheMot(nom) + root.update() + label=panel.Liste.dico_labels[nom] + label.event_generate("") + root.event_generate("") + root.update() + return jdcdisplay.panel_courant + +def change_commandcomm(text,panel): + panel.widget_text.setvalue(text) + root.update() + panel.bouton_val.invoke() + return panel + +def create_command(nom,panel): + panel.nb.selectpage('Commande') + root.update() + panel.command_entry.setentry(nom) + panel.command_entry.component('entry').focus_set() + root.event_generate("") + root.update() + label=panel.liste_command.dico_labels[nom] + label.event_generate("") + label.event_generate("") + #root.event_generate("") + root.update() + panel=jdcdisplay.panel_courant + return panel + +def create_comment(text,panel): + panel.nb.selectpage('Commentaire') + panel.ajout_commentaire() + root.update() + panel=jdcdisplay.panel_courant + panel.widget_text.setvalue(text) + root.update() + panel.bouton_val.invoke() + #panel.change_valeur() + return panel + +def create_param(nom,valeur,panel): + panel.nb.selectpage('Commentaire') + panel.ajout_parametre() + root.update() + panel=jdcdisplay.panel_courant + if nom: + panel.entry_nom.delete(0,"end") + panel.entry_nom.insert(0,nom) + panel.entry_nom.event_generate("") + panel.entry_val.delete(0,"end") + panel.entry_val.insert(0,valeur) + panel.entry_val.event_generate("") + panel.bouton_val.invoke() + root.update() + return panel + +def create_formule(nom,args,expr,panel): + panel=create_command("FORMULE",panel) + panel.entry_nom.delete(0,"end") + panel.entry_nom.insert(0,nom) + panel.entry_nom.event_generate("") + panel.entry_arg.delete(0,"end") + panel.entry_arg.insert(0,args) + panel.entry_arg.event_generate("") + panel.entry_exp.delete(0,"end") + panel.entry_exp.insert(0,expr) + panel.entry_exp.event_generate("") + panel.bouton_val.invoke() + root.update() + return panel + +def nomme_concept(nom,panel): + panel.nb.selectpage('Concept') + root.update() + panel._any.delete(0,"end") + panel._any.insert(0,nom) + panel.but_ok.invoke() + root.update() + return jdcdisplay.panel_courant + +def select_mcf(nom,ind,node): + panel=select_child(nom,node) + parent=panel.node + parent.expand() + parent.select_next(ind) + panel=jdcdisplay.panel_courant + panel.node.expand() + return panel + +def select_child(nom,node): + """node est le parent dont on veut le fils nom""" + for n in node.children: + if n.item.nom == nom: + n.select() + root.update() + panel= jdcdisplay.panel_courant + panel.node.expand() + return panel + raise UnKnownNode(nom) + +def select_node(node): + node.select() + node.expand() + root.update() + return jdcdisplay.panel_courant + +def choose_valeur(valeur,panel): + panel.Liste_choix.afficheMot(valeur) + root.update() + label=panel.Liste_choix.dico_labels[valeur] + label.event_generate("") + label.event_generate("") + root.update() + +def choose_sdco(valeur,panel): + i = list(panel.listbox.get(0, 'end')).index(valeur) + panel.listbox.component("listbox").selection_set(i) + panel.listbox.component("listbox").focus_set() + panel.listbox.component("listbox").event_generate("") + root.update() + +def choose_assd(valeur,panel): + i = list(panel.listbox.get(0, 'end')).index(valeur) + panel.listbox.component("listbox").selection_set(i) + panel.but_val.invoke() + root.update() + +def set_valeur(valeur,panel): + panel.entry.delete(0,"end") + panel.entry.insert(0,valeur) + panel.entry.event_generate("") + root.update() + +def set_sdco(valeur,panel): + panel.entry_co.delete(0,"end") + panel.entry_co.insert(0,valeur) + panel.entry_co.event_generate("") + root.update() + +def set_complexe(valeur,panel): + panel.entry3.setentry(valeur) + panel.entry3.component('entry').focus_set() + panel.entry3.event_generate("") + root.update() + +def add_valeur_into(valeur,panel): + label=panel.Liste_choix.dico_labels[valeur] + label.event_generate("<1>") + panel.bouton_add.invoke() + root.update() + +def add_valeur(valeur,panel): + panel.entry.delete(0,"end") + panel.entry.insert(0,valeur) + panel.entry.event_generate("") + root.update() + +def valider_valeur(panel): + panel.bouton_accepter.invoke() + root.update() + +def copier_coller(): + root.event_generate("") + root.event_generate("") + root.update() + return jdcdisplay.panel_courant + diff --git a/Tests/testihm/testihm1.py b/Tests/testihm/testihm1.py new file mode 100644 index 00000000..e6650ca8 --- /dev/null +++ b/Tests/testihm/testihm1.py @@ -0,0 +1,336 @@ +# -*- coding: utf-8 -*- +# Modules Python +import os +import unittest +import difflib +import compare +import sys +import Tkinter + +# Modules Eficas +import prefs +from Editeur import eficas_go +from Editeur import splash +from Editeur import session +from Editeur import eficas +from Editeur import images +from common import * + + +class TestCase(unittest.TestCase): + def setUp(self): + self.root = Tkinter.Tk() + images.update_cache() + # Analyse des arguments de la ligne de commande + options=session.parse([]) + options.cata="v8.2" + pass + + def tearDown(self): + self.root.destroy() + init_common(None,None) + pass + + def test000(self): + root=self.root + code="ASTER" + splash.init_splash(root,code=code,titre="Lancement d'EFICAS pour %s" %code) + splash._splash.configure(text="Chargement d'EFICAS en cours.\n Veuillez patienter ...") + app=eficas.EFICAS(root,code=code) + j=app.bureau.newJDC() + jdcdisplay=app.bureau.JDCDisplay_courant + init_common(root,jdcdisplay) + + # commande DEBUT + co=j.addentite("DEBUT",0) + # commande FIN + co=j.addentite("FIN",1) + + jdctree=jdcdisplay.tree.tree.children[0] + panel=select_child("DEBUT",jdctree) + + panel=create_param("P1",9.8,panel) + panel=create_param("P2",8.8,panel) + panel=create_param("P3",7,panel) + panel=create_param("P4","[2,3,4]",panel) + panel=create_param("P5","P3*P1",panel) + panel=create_param(None,"P1-3",panel) + panel=create_comment("Pas trouve shellpanel",panel) + + #commnde LIRE_MAILLAGE + panel=create_command("LIRE_MAILLAGE",panel) + command=panel.node + panel=nomme_concept("MAILLA2",panel) + panel=select_node(command) + panel=create_mocle("UNITE",panel) + panel=set_valeur("P4[1]",panel) + command.collapse() + panel=select_node(command) + #FORMULE + panel=create_formule("az","a,z","a+z",panel) + #commande AFFE_MODELE + panel=create_command("AFFE_MODELE",panel) + command=panel.node + select_child("MAILLAGE",command) + panel=select_node(command) + panel=create_mocle("AFFE",panel) + parent=panel.node + panel=select_child("PHENOMENE",parent) + choose_valeur("MECANIQUE",panel) + panel=select_child("b_mecanique",parent) + panel=select_child("MODELISATION",panel.node) + add_valeur_into("3D",panel) + add_valeur_into("3D_FLUIDE",panel) + valider_valeur(panel) + panel=select_node(parent) + panel=create_mocle("TOUT",panel) + choose_valeur("OUI",panel) + panel=select_node(command) + panel=nomme_concept("MO",panel) + command.collapse() + #fin commande AFFE_MODELE + panel=copier_coller() + command=panel.node + panel=create_mocle("AFFE",panel) + panel=select_node(command) + panel=create_mocle("AFFE",panel) + panel=select_mcf("AFFE",1,command) + parent=panel.node + panel=create_mocle("GROUP_NO",panel) + add_valeur("'GNP3','GNP5','GNP6','GNP7','GNP8','GNP9','GNP10','GNP11','GNP12'",panel) + valider_valeur(panel) + panel=select_child("PHENOMENE",parent) + choose_valeur("ACOUSTIQUE",panel) + panel=select_child("b_acoustique",parent) + panel=select_child("MODELISATION",panel.node) + add_valeur_into("PLAN",panel) + valider_valeur(panel) + + panel=select_mcf("AFFE",2,command) + parent=panel.node + panel=create_mocle("GROUP_MA",panel) + add_valeur("MASSES",panel) + valider_valeur(panel) + panel=select_child("PHENOMENE",parent) + choose_valeur("THERMIQUE",panel) + panel=select_child("b_thermique",parent) + panel=select_child("MODELISATION",panel.node) + add_valeur_into("COQUE",panel) + valider_valeur(panel) + + panel=select_node(command) + panel=nomme_concept("AFFE1",panel) + command.collapse() + #fin commande AFFE_MODELE + #commande AFFE_CARA_ELEM + panel=create_command("AFFE_CARA_ELEM",panel) + command=panel.node + panel=select_node(command) + panel=create_mocle("POUTRE",panel) + parent=panel.node + panel=select_child("SECTION",parent) + choose_valeur("CERCLE",panel) + panel=select_child("b_cercle",parent) + panel=select_child("b_constant",panel.node) + p=panel.node + panel=select_child("CARA",p) + add_valeur_into("R",panel) + add_valeur_into("EP",panel) + valider_valeur(panel) + panel=select_child("VALE",p) + add_valeur("1,2",panel) + valider_valeur(panel) + panel=select_node(parent) + panel=create_mocle("GROUP_MA",panel) + add_valeur("GR1,GR2",panel) + valider_valeur(panel) + panel=select_child("MODELE",command) + choose_assd("MO",panel) + panel=select_node(command) + panel=nomme_concept("CARA",panel) + command.collapse() + #fin commande AFFE_CARA_ELEM + panel=create_command("DEFI_FONCTION",panel) + command=panel.node + panel=create_mocle("VALE",panel) + add_valeur("5.0,3.0",panel) + add_valeur("P4[1],P3",panel) + valider_valeur(panel) + panel=select_child("NOM_PARA",command) + choose_valeur("DX",panel) + panel=select_node(command) + panel=nomme_concept("F1",panel) + command.collapse() + #fin DEFI_FONCTION + panel=create_command("DEFI_FONCTION",panel) + command=panel.node + panel=create_mocle("VALE_C",panel) + add_valeur("5.0,7.0,9.0",panel) + add_valeur("9.0,8.0,7.0",panel) + valider_valeur(panel) + panel=select_child("NOM_PARA",command) + choose_valeur("DRX",panel) + panel=select_node(command) + panel=nomme_concept("F3",panel) + command.collapse() + #fin DEFI_FONCTION +#MATER2=DEFI_MATERIAU(ELAS=_F(E=100000000000.0, +# NU=0.0,), +# ECRO_ASYM_LINE=_F(DC_SIGM_EPSI=0.0, +# SY_C=200000000.0, +# DT_SIGM_EPSI=0.0, +# SY_T=50000000.0,),); + + panel=create_command("DEFI_MATERIAU",panel) + command=panel.node + panel=create_mocle("ELAS",panel) + p=panel.node + panel=select_child("E",p) + set_valeur("100000000000.0",panel) + panel=select_child("NU",p) + set_valeur("0.0",panel) + panel=select_node(command) + panel=create_mocle("ECRO_ASYM_LINE",panel) + p=panel.node + panel=select_child("DC_SIGM_EPSI",p) + set_valeur("0.0",panel) + panel=select_child("SY_C",p) + set_valeur("200000000.0",panel) + panel=select_child("DT_SIGM_EPSI",p) + set_valeur("0.0",panel) + panel=select_child("SY_T",p) + set_valeur("50000000.0",panel) + panel=select_node(command) + panel=nomme_concept("MATER2",panel) + command.collapse() + #fin DEFI_MATERIAU + #PS1=DEFI_PARA_SENSI(VALE=1.0,); + #PS2=DEFI_PARA_SENSI(VALE=1.0,); + #PS3=DEFI_PARA_SENSI(VALE=1.0,); + panel=create_command("DEFI_PARA_SENSI",panel) + command=panel.node + panel=select_child("VALE",command) + set_valeur("1.0",panel) + panel=select_node(command) + panel=nomme_concept("PS1",panel) + command.collapse() + panel=create_command("DEFI_PARA_SENSI",panel) + command=panel.node + panel=select_child("VALE",command) + set_valeur("1.0",panel) + panel=select_node(command) + panel=nomme_concept("PS2",panel) + command.collapse() + panel=create_command("DEFI_PARA_SENSI",panel) + command=panel.node + panel=select_child("VALE",command) + set_valeur("1.0",panel) + panel=select_node(command) + panel=nomme_concept("PS3",panel) + command.collapse() +#CHMAT2=AFFE_MATERIAU(MAILLAGE=MAIL, +# AFFE=_F(TOUT='OUI', +# MATER=MATER2,),); + panel=create_command("AFFE_MATERIAU",panel) + command=panel.node + panel=select_child("MAILLAGE",command) + panel=select_child("AFFE",command) + affe=panel.node + panel=create_mocle("TOUT",panel) + choose_valeur("OUI",panel) + panel=select_child("MATER",affe) + add_valeur_into("MATER2",panel) + valider_valeur(panel) + panel=select_node(command) + panel=nomme_concept("CHMAT2",panel) + command.collapse() +#AAAZ=AFFE_CHAR_THER(MODELE=AFFE1, +# TEMP_IMPO=_F(TOUT='OUI', +# TEMP=0.0,),); + panel=create_command("AFFE_CHAR_THER",panel) + command=panel.node + panel=create_mocle("TEMP_IMPO",panel) + temp=panel.node + panel=create_mocle("TOUT",panel) + choose_valeur("OUI",panel) + panel=select_node(temp) + panel=create_mocle("TEMP",panel) + panel=set_valeur("0.0",panel) + panel=select_child("MODELE",command) + choose_assd("AFFE1",panel) + panel=select_node(command) + panel=nomme_concept("AAAZ",panel) + command.collapse() +#TH1=THER_LINEAIRE(MODELE=AFFE1, +# CHAM_MATER=CHMAT2, +# EXCIT=_F(CHARGE=AAAZ,), +# SENSIBILITE=(PS1,PS2,),); + panel=create_command("THER_LINEAIRE",panel) + command=panel.node + panel=select_child("MODELE",command) + choose_assd("AFFE1",panel) + panel=select_child("CHAM_MATER",command) + panel=select_child("EXCIT",command) + panel=select_child("CHARGE",panel.node) + panel=select_node(command) + panel=create_mocle("SENSIBILITE",panel) + add_valeur_into("PS1",panel) + add_valeur_into("PS2",panel) + valider_valeur(panel) + panel=select_node(command) + panel=nomme_concept("TH1",panel) + command.collapse() +#ACA1=AFFE_CHAR_ACOU(MODELE=AFFE1, +# PRES_IMPO=_F(TOUT='OUI', +# PRES=('RI',3.0,3.0,),),); + panel=create_command("AFFE_CHAR_ACOU",panel) + command=panel.node + panel=create_mocle("PRES_IMPO",panel) + pres=panel.node + panel=create_mocle("TOUT",panel) + choose_valeur("OUI",panel) + panel=select_child("MODELE",command) + choose_assd("AFFE1",panel) + panel=select_child("PRES",pres) + set_complexe("'RI',3.0,3.0",panel) + panel=select_node(command) + panel=nomme_concept("ACA1",panel) + command.collapse() +#MACRO_MATR_ASSE(MODELE=AFFE1, +# NUME_DDL=CO('DDL1'), +# MATR_ASSE=_F(MATRICE=CO('MAT1'), +# OPTION='RIGI_THER',),); + panel=create_command("MACRO_MATR_ASSE",panel) + command=panel.node + panel=select_child("NUME_DDL",command) + set_sdco("DDL1",panel) + panel=select_child("MODELE",command) + choose_assd("AFFE1",panel) + panel=select_child("MATR_ASSE",command) + matr=panel.node + panel=select_child("OPTION",matr) + choose_valeur("RIGI_THER",panel) + panel=select_child("MATRICE",matr) + set_sdco("MAT1",panel) + panel=select_node(command) + command.collapse() +#MACRO_MATR_ASSE(MODELE=AFFE1, +# NUME_DDL=DDL1, +# MATR_ASSE=_F(MATRICE=MAT1, +# OPTION='RIGI_THER',),); + panel=create_command("MACRO_MATR_ASSE",panel) + command=panel.node + panel=select_child("NUME_DDL",command) + choose_sdco("DDL1",panel) + panel=select_child("MODELE",command) + choose_assd("AFFE1",panel) + panel=select_child("MATR_ASSE",command) + matr=panel.node + panel=select_child("OPTION",matr) + choose_valeur("RIGI_THER",panel) + panel=select_child("MATRICE",matr) + set_sdco("MAT2",panel) + panel=select_node(command) + command.collapse() + + assert j.isvalid(),j.report() diff --git a/Tests/testihm/testihm2.py b/Tests/testihm/testihm2.py new file mode 100644 index 00000000..71e4d640 --- /dev/null +++ b/Tests/testihm/testihm2.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# Modules Python +import os +import unittest +import difflib +import compare +import sys +import Tkinter + +# Modules Eficas +import prefs +from Editeur import eficas_go +from Editeur import splash +from Editeur import session +from Editeur import eficas +from Editeur import images +from common import * + + +class TestCase(unittest.TestCase): + def setUp(self): + self.root = Tkinter.Tk() + images.update_cache() + # Analyse des arguments de la ligne de commande + options=session.parse([]) + options.cata="v8.2" + pass + + def tearDown(self): + self.root.destroy() + init_common(None,None) + pass + + def test000(self): + root=self.root + code="ASTER" + splash.init_splash(root,code=code,titre="Lancement d'EFICAS pour %s" %code) + splash._splash.configure(text="Chargement d'EFICAS en cours.\n Veuillez patienter ...") + app=eficas.EFICAS(root,code=code) + j=app.bureau.newJDC() + jdcdisplay=app.bureau.JDCDisplay_courant + init_common(root,jdcdisplay) + + # commande DEBUT + co=j.addentite("DEBUT",0) + # commande FIN + co=j.addentite("FIN",1) + + jdctree=jdcdisplay.tree.tree.children[0] + panel=select_child("DEBUT",jdctree) + panel=create_command("LIRE_MAILLAGE",panel) + panel=nomme_concept("MA",panel) + + panel=create_command("AFFE_MODELE",panel) + command=panel.node + select_child("MAILLAGE",command) + panel=select_node(command) + panel=create_mocle("AFFE",panel) + parent=panel.node + panel=select_child("PHENOMENE",parent) + choose_valeur("MECANIQUE",panel) + panel=select_child("b_mecanique",parent) + panel=select_child("MODELISATION",panel.node) + add_valeur_into("3D",panel) + add_valeur_into("3D_FLUIDE",panel) + valider_valeur(panel) + panel=select_node(parent) + panel=create_mocle("TOUT",panel) + choose_valeur("OUI",panel) + panel=select_node(command) + panel=nomme_concept("MO",panel) + + assert j.isvalid(),j.report() diff --git a/Tests/testihm/testihm3.py b/Tests/testihm/testihm3.py new file mode 100644 index 00000000..7fa615f3 --- /dev/null +++ b/Tests/testihm/testihm3.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +# Modules Python +import os +import unittest +import difflib +import compare +import sys +import Tkinter + +# Modules Eficas +import prefs +from Editeur import eficas_go +from Editeur import splash +from Editeur import session +from Editeur import eficas +from Editeur import images +from common import * + + +class TestCase(unittest.TestCase): + def setUp(self): + self.root = Tkinter.Tk() + images.update_cache() + # Analyse des arguments de la ligne de commande + options=session.parse([]) + options.cata="petit" + pass + + def tearDown(self): + self.root.destroy() + init_common(None,None) + pass + + def test000(self): + root=self.root + code="ASTER" + splash.init_splash(root,code=code,titre="Lancement d'EFICAS pour %s" %code) + splash._splash.configure(text="Chargement d'EFICAS en cours.\n Veuillez patienter ...") + app=eficas.EFICAS(root,code=code) + j=app.bureau.newJDC() + jdcdisplay=app.bureau.JDCDisplay_courant + init_common(root,jdcdisplay) + + # commande DEBUT + co=j.addentite("DEBUT",0) + # commande FIN + co=j.addentite("FIN",1) + + jdctree=jdcdisplay.tree.tree.children[0] + panel=select_child("DEBUT",jdctree) + panel=create_command("TESTS_VALID",panel) + command=panel.node + panel=select_child("LongStr",command) + set_valeur("aaa",panel) + panel=select_child("ListStr",command) + add_valeur("aaa",panel) + add_valeur("bbbb,ccc",panel) + valider_valeur(panel) + panel=select_child("PairVal",command) + add_valeur(2,panel) + add_valeur("4,6",panel) + valider_valeur(panel) + panel=select_child("RangeVal",command) + set_valeur(4,panel) + panel=select_child("CardVal",command) + add_valeur("4,6,5,7",panel) + valider_valeur(panel) + panel=select_child("EnumVal",command) + choose_valeur(3,panel) + panel=select_child("OrdList",command) + add_valeur("4,6,5,7",panel) + valider_valeur(panel) + panel=select_child("OrdList2",command) + add_valeur_into(2,panel) + valider_valeur(panel) + panel=select_child("TypeVal",command) + set_valeur(5,panel) + panel=select_child("Compul",command) + add_valeur("2",panel) + add_valeur("1",panel) + valider_valeur(panel) + panel=select_child("CompulInto",command) + add_valeur_into(2,panel) + add_valeur_into(1,panel) + valider_valeur(panel) + panel=select_child("Norep",command) + add_valeur("2",panel) + valider_valeur(panel) + panel=select_child("NorepInto",command) + add_valeur_into(2,panel) + valider_valeur(panel) + + panel=select_node(command) + panel=nomme_concept("MA",panel) + + assert j.isvalid(),j.report() diff --git a/Tests/testihm/testihm4.py b/Tests/testihm/testihm4.py new file mode 100644 index 00000000..4fdd6193 --- /dev/null +++ b/Tests/testihm/testihm4.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Modules Python +import os +import unittest +import difflib +import compare +import sys +import Tkinter + +# Modules Eficas +import prefs +from Editeur import eficas_go +from Editeur import splash +from Editeur import session +from Editeur import eficas +from Editeur import images +from common import * + + +class TestCase(unittest.TestCase): + def setUp(self): + self.root = Tkinter.Tk() + images.update_cache() + # Analyse des arguments de la ligne de commande + options=session.parse([]) + options.cata="v8.2" + pass + + def tearDown(self): + self.root.destroy() + init_common(None,None) + pass + + def test000(self): + root=self.root + code="ASTER" + splash.init_splash(root,code=code,titre="Lancement d'EFICAS pour %s" %code) + splash._splash.configure(text="Chargement d'EFICAS en cours.\n Veuillez patienter ...") + app=eficas.EFICAS(root,code=code) + file=os.path.join(prefs.INSTALLDIR,"Tests/testelem/az.comm") + j=app.bureau.openJDC(file=file) + jdcdisplay=app.bureau.JDCDisplay_courant + init_common(root,jdcdisplay) + jdctree=jdcdisplay.tree.tree.children[0] + #commentariser commande MACRO_MATR_ASSE + panel=select_child("MACRO_MATR_ASSE",jdctree) + panel=comment_command(panel) + #decommentariser commande MACRO_MATR_ASSE + panel=uncomment_command(panel) + #creation commande commentée + panel=create_command("LIRE_MAILLAGE",panel) + panel=comment_command(panel) + panel=change_commandcomm("mm=LIRE_MAILLAGE(INFO=2,UNITE=21)",panel) + panel=uncomment_command(panel) + panel=select_child("DEFI_FONCTION",jdctree) + delete_node(panel) + + assert j.isvalid(),j.report() -- 2.39.2