Salome HOME
Bring back testcontainermanager and testresourcemanager to salome test.
[modules/kernel.git] / src / LifeCycleCORBA_SWIG / Test / testcontainermanager.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016  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     host1=co.getHostName()
49     name1="/Containers/%s/MyContainer" % host1
50     self.assertEqual(co._get_name(), name1)
51     co=cm.GiveContainer( p )
52     host2=co.getHostName()
53     name2="/Containers/%s/MyContainer" % host2
54     self.assertEqual(co._get_name(), name2)
55
56   def test1(self):
57     """"""
58     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
59     p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="get",resource_params=rp)
60     co=cm.GiveContainer( p )
61     host1=co.getHostName()
62     name1="/Containers/%s/MyContainer" % host1
63     self.assertEqual(co._get_name(), name1)
64     co=cm.GiveContainer( p )
65     host2=co.getHostName()
66     name2="/Containers/%s/MyContainer" % host2
67     self.assertEqual(co._get_name(), name2)
68
69   def test2(self):
70     """"""
71     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
72     p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="getorstart",resource_params=rp)
73     co=cm.GiveContainer( p )
74     host1=co.getHostName()
75     name1="/Containers/%s/MyContainer" % host1
76     self.assertEqual(co._get_name(), name1)
77     co=cm.GiveContainer( p )
78     host2=co.getHostName()
79     name2="/Containers/%s/MyContainer" % host2
80     self.assertEqual(co._get_name(), name2)
81
82
83 if __name__ == '__main__':
84   #suite = unittest.TestLoader().loadTestsFromTestCase(TestContainerManager)
85   #unittest.TextTestRunner().run(suite)
86   unittest.main()