Salome HOME
fe13697b8d23b22cee012ca44bbb14ae8a483a3d
[modules/kernel.git] / src / LifeCycleCORBA_SWIG / Test / testcontainermanager.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import unittest
22 import salome
23 import Engines
24 import LifeCycleCORBA
25 salome.salome_init()
26 cm= salome.lcc.getContainerManager()
27 rm= salome.lcc.getResourcesManager()
28
29 class TestContainerManager(unittest.TestCase):
30   """
31 Test with catalog :
32 <!DOCTYPE ResourcesCatalog>
33 <resources>
34    <machine hostname="claui2c6" >
35    </machine>
36    <machine hostname="clt10br" >
37    </machine>
38 </resources>
39 """
40   def setUp(self):
41     pass
42
43   def test0(self):
44     """"""
45     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
46     p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="start",resource_params=rp)
47     co=cm.GiveContainer( p )
48     self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer")
49     co=cm.GiveContainer( p )
50     self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer")
51
52   def test1(self):
53     """"""
54     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
55     p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="get",resource_params=rp)
56     co=cm.GiveContainer( p )
57     self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer")
58     co=cm.GiveContainer( p )
59     self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer")
60
61   def test2(self):
62     """"""
63     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
64     p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="getorstart",resource_params=rp)
65     co=cm.GiveContainer( p )
66     self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer")
67     co=cm.GiveContainer( p )
68     self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer")
69
70
71 if __name__ == '__main__':
72   suite = unittest.TestLoader().loadTestsFromTestCase(TestContainerManager)
73   unittest.TextTestRunner().run(suite)
74