1 # Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 class TestLoader(unittest.TestCase):
28 SALOMERuntime.RuntimeSALOME_setRuntime()
29 self.r = pilot.getRuntime()
30 self.l = loader.YACSLoader()
31 self.e = pilot.ExecutorSwig()
39 def test1_FileNotExist(self):
40 # --- File does not exist
43 p = self.l.load("nonexisting")
45 print("IO Error: ", ex)
47 # except pilot.invalid_argument as ex:
48 # print("invalid_argument:",str(ex))
50 self.assertTrue(retex is not None, "exception not raised, or wrong type")
53 def test2_parseError(self):
54 # --- File exists but parse error
57 p = self.l.load("samples/bid.xml")
58 except ValueError as ex:
59 print("Caught ValueError Exception:",ex)
61 expected="LogRecord: parser:ERROR:from node node5 does not exist in control link: node5->b2 context: b1. (samples/bid.xml:53)\n"
62 self.assertTrue(p.getLogger("parser").getStr() == expected, "error not found: "+p.getLogger("parser").getStr())
65 def test3_normal(self):
66 # --- File exists and no parsing problem
68 p = self.l.load("samples/aschema.xml")
69 print(p.getLogger("parser").getStr())
72 for k in p.typeMap: print(k)
73 for k in p.nodeMap: print(k)
74 for k in p.inlineMap: print(k)
75 for k in p.serviceMap: print(k)
76 print(self.e.getTasksToLoad())
78 self.assertEqual(106, p.getChildByName('node48').getEffectiveState())
79 except pilot.Exception as ex:
80 print("YACS exception:",ex)
85 if __name__ == '__main__':
88 with open("/tmp/" + U + "/UnitTestsResult", 'a') as f:
89 f.write(" --- TEST src/yacsloader: testLoader.py\n")
90 suite = unittest.makeSuite(TestLoader)
91 result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
92 sys.exit(not result.wasSuccessful())