Salome HOME
modif Adao 7 6
[tools/eficas.git] / Tests / testelem / testjdc2.py
1 # -*- coding: iso-8859-1 -*-
2 import cata5
3
4 import unittest,re,os
5 import compare
6
7 class TestJDCCase(unittest.TestCase):
8
9    def test1(self):
10       text="""
11 # OP2 : CO converti en concept2 ou concept2. Retourne concept
12 # OP6 : uniquement CO converti en concept2. Retourne concept
13 # OP3 : CO converti en concept ou concept. Retourne concept
14 co0=OP2(MATR=CO("x1"))
15 co2=OP6(MATR=CO("xx"))
16 co3=OP3(MATR={"CHAM":"R","MM":co2})
17 """
18       self.execute(cata5,text)
19
20    def test2(self):
21       text="""
22 # OP2 : CO converti en concept2 ou concept2. Retourne concept
23 # OP5 : uniquement CO converti en concept2. Retourne concept
24 co0=OP2(MATR=CO("x1"))
25 co1=OP5(MATR=co0)
26 """
27       expected="""DEBUT CR validation : bidon
28    Etape : OP5    ligne : 5    fichier : 'bidon'
29       Mot-clé simple : MATR
30          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31          ! concept co0 de type concept (de type <class 'cata5.concept'>) n'est pas d'un !
32          ! type autorisé: (<class 'Accas.A_ASSD.CO'>,)                                  !
33          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
34       Fin Mot-clé simple : MATR
35    Fin Etape : OP5
36 FIN CR validation :bidon
37 """
38       self.execute(cata5,text,err3=expected)
39
40    def test3(self):
41       text="""
42 # OP2 : CO converti en concept2 ou concept2. Retourne concept
43 co0=OP2(MATR=CO("x1"))
44 co1=OP2(MATR=x1)
45 co2=OP2(MATR=co0)
46 """
47       expected="""DEBUT CR validation : bidon
48    Etape : OP2    ligne : 5    fichier : 'bidon'
49       Mot-clé simple : MATR
50          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
51          ! concept co0 de type concept (de type <class 'cata5.concept'>) n'est pas d'un !
52          ! type autorisé: (<class 'Accas.A_ASSD.CO'>, <class 'cata5.concept2'>)         !
53          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
54       Fin Mot-clé simple : MATR
55    Fin Etape : OP2
56 FIN CR validation :bidon
57 """
58       self.execute(cata5,text,err3=expected)
59
60    def test8(self):
61       text="""
62 co2=OP14(MATR=CO("xx"))
63 """
64       expected=""
65       self.execute(cata5,text,err4=expected)
66
67    def test12(self):
68       text="""
69 co2=OP18(MATR=CO("xx"))
70 co3=OP2(MATR=xx)
71 co4=OP11(MATR=xx)
72 """
73       expected=""
74       self.execute(cata5,text,err4=expected)
75
76    def test13(self):
77       text="""
78 co2=OP10(MATR=CO("xx"))
79 """
80       expected="""DEBUT CR validation : bidon
81    Etape : OP10    ligne : 2    fichier : 'bidon'
82       Mot-clé simple : MATR
83          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
84          ! concept xx de type CO (de type <class 'Accas.A_ASSD.CO'>) n'est pas d'un type !
85          ! autorisé: (<class 'cata5.concept2'>,)                                         !
86          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
87       Fin Mot-clé simple : MATR
88    Fin Etape : OP10
89 FIN CR validation :bidon
90 """
91       self.execute(cata5,text,err3=expected)
92
93    def test16(self):
94       text="""
95 co=OP22(MATR=CO("xx"))
96 """
97       self.execute(cata5,text)
98
99    def test17(self):
100       text="""
101 co=OP22(MATR=CO("xx"))
102 co2=OP22(MATR=xx)
103 """
104       expected="""DEBUT CR validation : bidon
105    Etape : OP22    ligne : 3    fichier : 'bidon'
106       Mot-clé simple : MATR
107          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
108          ! concept xx de type concept4 (de type <class 'cata5.concept4'>) n'est pas d'un !
109          ! type autorisé: (<class 'Accas.A_ASSD.CO'>,)                                   !
110          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
111       Fin Mot-clé simple : MATR
112    Fin Etape : OP22
113 FIN CR validation :bidon
114 """
115       self.execute(cata5,text,err3=expected)
116
117    def setUp(self):
118       pass
119
120    def tearDown(self):
121       pass
122
123    def execute(self,cata,text_jdc,err1="",err2="",err3="",err4=""):
124       j=cata.JdC(procedure=text_jdc,cata=cata,nom="bidon")
125       j.actif_status=1
126       j.fico=None
127       j.set_par_lot("OUI")
128       # On compile le texte Python
129       j.compile()
130       # On initialise les tops de mesure globale de temps d'execution du jdc
131       j.cpu_user=os.times()[0]
132       j.cpu_syst=os.times()[1]
133       j.impr_macro='NON'
134
135       #print j.cr
136       if err1 == "":
137         self.assert_(j.cr.estvide(),msg='Erreur non attendue dans compile (err1):\n%s' % str(j.cr))
138       else:
139         self.assert_(self.check(err1,str(j.cr)),msg='Erreur non attendue dans compile (err1):\n%s\n!=\n%s' % (str(j.cr),err1))
140         j.supprime()
141         return
142
143       j.exec_compile()
144       #print j.cr
145       if err2 == "":
146         self.assert_(j.cr.estvide(),msg='Erreur non attendue dans exec_compile (err2):\n%s' % str(j.cr))
147       else:
148         self.assert_(self.check(err2,str(j.cr)),msg='Erreur non attendue dans exec_compile(err2):\n%s\n!=\n%s' % (str(j.cr),err2))
149         j.supprime()
150         return
151
152       cr=j.report()
153       #print cr
154       if err3 == "":
155         self.assert_(cr.estvide(),msg='Erreur non attendue dans exec_compile (err3):\n%s' % str(cr))
156       else:
157         self.assert_(self.check(err3,str(cr)),msg='Erreur non attendue dans exec_compile(err3):\n%s\n!=\n%s' % (str(cr),err3))
158         j.supprime()
159         return
160
161       j.set_par_lot("NON")
162
163       j.supprime()
164
165    def check(self,want,got):
166       return compare.check(want,got)