Salome HOME
a1272a9786c755e89502488208efe56b7345eefa
[modules/kernel.git] / src / SALOMESDS / TestSalomeSDSHelper0.py
1 # Copyright (C) 2015-2023  CEA/DEN, EDF R&D, OPEN CASCADE
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 import SALOME
20 import pickle
21 import salome
22 import sys
23
24 scopeName="Scope1"
25 varName="a"
26
27 def obj2Str(obj):
28     return pickle.dumps(obj,pickle.HIGHEST_PROTOCOL)
29
30 def str2Obj(strr):
31     return pickle.loads(strr)
32
33 def waitKey(IORNS):
34     import Engines
35     import CORBA
36     orb = CORBA.ORB_init([''])
37     ns = orb.string_to_object(IORNS)
38     import SALOME
39     dsm = orb.string_to_object(ns.Resolve("/DataServerManager").decode())
40     dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
41     assert(not isCreated)
42     wk=dss.waitForKeyInVar(varName,obj2Str("ef"))
43     wk.waitFor()
44     return str2Obj(dss.waitForMonoThrRev(wk))==[11,14,100]
45
46 if __name__=="__main__":
47     IORNS = sys.argv[-1]
48     with salome.SessionContextManager():
49         if waitKey(IORNS) is not True:
50             raise AssertionError("Not the expected result")