1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
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
20 # Author : Anthony Geay
28 class SalomeSDS2Test(unittest.TestCase):
31 a=SalomeSDSClt.CreateRdExtGlobalVar([],"a","Scope0")
32 self.assertEqual(a.local_copy(),[])
34 self.assertEqual(a.local_copy(),[5])
35 self.assertRaises(SALOME.SALOME_Exception,a.__delitem__,0)
37 self.assertEqual(a.local_copy(),[5,["rt"]])
39 self.assertEqual(a.local_copy(),[5,["rt",8]])
41 self.assertEqual(a.local_copy(),[5,["rt",8],5,["rt",8]])
43 self.assertEqual(a.local_copy(),[5,["rt",8],5,["rt",8],["rt",8]])
45 self.assertEqual(a.local_copy(),[5,["rt",8],5,["rt",8],["rt",8,7]])
46 a._var_ptr.getMyDataScopeServer().deleteVar("a")
50 a=SalomeSDSClt.CreateRdExtGlobalVar({},"a","Scope0")
52 self.assertEqual(a.local_copy(),{"ab":4})
54 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5]})
56 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77]})
57 a.__setitem__("ef",["a","bb"])
58 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77],"ef":["a","bb"]})
59 self.assertRaises(SALOME.SALOME_Exception,a.__setitem__,"ef",["a","bb"])
60 self.assertRaises(SALOME.SALOME_Exception,a.__setitem__,"ef",["a","bb","ccc"])
62 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77],"ef":["a","bb","ccc"]})
64 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77],"ef":["a","bb","ccc"],"gh":{"ab":4,"cd":[5,77],"ef":["a","bb","ccc"]}})
65 a["gh"]["cd"].append(99) ; a["cd"].append(88)
66 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77,88],"ef":["a","bb","ccc"],"gh":{"ab":4,"cd":[5,77,99],"ef":["a","bb","ccc"]}})
67 a._var_ptr.getMyDataScopeServer().deleteVar("a")
70 def testReadOnly1(self):
71 a=SalomeSDSClt.CreateRdOnlyGlobalVar({"ab":4,"cd":[5,77]},"a","Scope0")
72 self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77]})
73 self.assertRaises(AttributeError,a.__getitem__,"ab")
74 a._var_ptr.getMyDataScopeServer().deleteVar("a")