2 # Copyright (C) 2006-2023 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 Various non regression tests.
35 class TestEdit(unittest.TestCase):
38 SALOMERuntime.RuntimeSALOME_setRuntime()
39 self.r = pilot.getRuntime()
40 self.l = loader.YACSLoader()
41 self.e = pilot.ExecutorSwig()
42 # We need a catalog which contains only one resource named "localhost"
43 # with NB_NODE cores. The modifications made here are not saved to the
46 resourceManager = salome.lcc.getResourcesManager()
47 resource_definition = resourceManager.GetResourceDefinition("localhost")
48 resource_definition.nb_node = NB_NODE
49 resource_definition.nb_proc_per_node = 1
50 resourceManager.AddResource(resource_definition, False, "")
51 resource_required = salome.ResourceParameters()
52 resource_required.can_run_containers = True
53 res_list = resourceManager.GetFittingResources(resource_required)
56 resourceManager.RemoveResource(r, False, "")
57 resource_definition = resourceManager.GetResourceDefinition("localhost")
58 self.assertEqual(resource_definition.nb_node, NB_NODE)
59 self.assertEqual(resource_definition.nb_proc_per_node, 1)
62 cm = salome.lcc.getContainerManager()
63 cm.ShutdownContainers()
65 def test_double_foreach_switch(self):
66 """ Two layers of nested foreach and switch structures.
68 proc = self.l.load("samples/foreach_switch_double.xml")
70 self.assertEqual(proc.getState(),pilot.DONE)
71 ok = proc.getChildByName("End").getOutputPort("ok")
72 self.assertTrue(ok, "Wrong result!")
74 if __name__ == '__main__':
75 dir_test = tempfile.mkdtemp(suffix=".yacstest")
76 file_test = os.path.join(dir_test,"UnitTestsResult")
77 with open(file_test, 'a') as f:
78 f.write(" --- TEST src/yacsloader: testFixes.py\n")
79 suite = unittest.makeSuite(TestEdit)
80 result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
81 sys.exit(not result.wasSuccessful())