Salome HOME
Merge branch 'akl/tests_update'
[modules/paravis.git] / test / VisuPrs / dump_study / B1.py
1 # Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This case corresponds to: /visu/dump_study/B1 case
21
22 from paravistest import tablesdir
23 from presentations import *
24 import paravis
25 from pvsimple import *
26
27 my_paravis = paravis.myParavis
28
29 # Import table from file
30 xls_file = tablesdir + "tables_test.xls"
31 table_reader = TableReader(FileName=xls_file)
32 if table_reader is None:
33     raise RuntimeError, "Table was not imported..."
34
35 table_reader.UpdatePipeline()
36 RenameSource("tables_test.xls", table_reader)
37
38 # 2. Dump Study
39 path_to_save = os.path.join(os.getenv("HOME"), "table.py")
40 SaveTrace(path_to_save)
41
42 # 3. Delete the created objects
43 Delete(table_reader)
44
45 # 4. Execution of the created script
46 execfile(path_to_save)
47
48 # 5. Check the restored table
49 restored_obj = FindSource("tables_test.xls")
50 if restored_obj is None:
51     raise RuntimeError, "There is no tables_test.xls table in the study (must be created by executed python script)!!!"
52
53 available_tables = restored_obj.GetPropertyValue("AvailableTables")
54
55 tables = ["Table:0", "Table toto 1", "sinus"]
56 errors = 0
57 count_not=0
58
59 for name in tables:
60     if name not in available_tables:
61         count_not += 1
62         print "ERROR!!! Table with ", name, " name was not found"
63         errors += 1
64     else:
65         print "\"" + name + "\" table was found..."
66
67 if count_not > 0:
68     print "ERROR!!! "+str(count_not)+" table(s) was(were) not found!!!"
69     errors += 1             
70 if errors > 0:
71     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."
72