Salome HOME
Update ParaVis non-regression test base in the following ways:
[modules/paravis.git] / test / VisuPrs / dump_study / B1.py
1 # Copyright (C) 2010-2015  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 from pvsimple import *
25
26 # Import table from file
27 xls_file = tablesdir + "tables_test.xls"
28 table_reader = TableReader(FileName=xls_file)
29 if table_reader is None:
30     raise RuntimeError, "Table was not imported..."
31
32 table_reader.UpdatePipeline()
33 RenameSource("tables_test.xls", table_reader)
34
35 # 2. Dump Study
36 path_to_save = os.path.join(os.getenv("HOME"), "table.py")
37 SaveTrace(path_to_save)
38
39 # 3. Delete the created objects
40 Delete(table_reader)
41
42 # 4. Execution of the created script
43 execfile(path_to_save)
44
45 # 5. Check the restored table
46 restored_obj = FindSource("tables_test.xls")
47 if restored_obj is None:
48     raise RuntimeError, "There is no tables_test.xls table in the study (must be created by executed python script)!!!"
49
50 available_tables = restored_obj.GetPropertyValue("AvailableTables")
51
52 tables = ["Table:0", "Table toto 1", "sinus"]
53 errors = 0
54 count_not=0
55
56 for name in tables:
57     if name not in available_tables:
58         count_not += 1
59         print "ERROR!!! Table with ", name, " name was not found"
60         errors += 1
61     else:
62         print "\"" + name + "\" table was found..."
63
64 if count_not > 0:
65     print "ERROR!!! "+str(count_not)+" table(s) was(were) not found!!!"
66     errors += 1
67 if errors > 0:
68     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."
69