Salome HOME
updated copyright message
[modules/shaper.git] / src / Config / Test / TestConfig.py
1 # Copyright (C) 2018-2023  CEA, EDF
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
20 from ModelAPI import *
21 from ConfigAPI import *
22
23 # register boolean property
24 Config_PropManager().registerProp("TestSection", "PropBool", "PropTitle", Config_Prop.Boolean)
25 # check property once again
26 Config_PropManager().registerProp("TestSection", "PropBool", "PropTitle", Config_Prop.Boolean, "true")
27 # check property value
28 assert(Config_PropManager().boolean("TestSection", "PropBool"))
29
30 # register real property
31 Config_PropManager().registerProp("TestSection", "PropDouble", "PropTitle", Config_Prop.Double, "12,5")
32 # check property (',' should be substituted by ".")
33 assert(Config_PropManager().real("TestSection", "PropDouble") == 12.5)
34
35 # register color property
36 Config_PropManager().registerProp("TestSection", "PropColor", "PropTitle", Config_Prop.Color, "#B00F00")
37 assert(len(Config_PropManager().color("TestSection", "PropColor")) == 3)
38
39 # check sections and properties are not empty
40 assert(len(Config_PropManager().getSections()) > 0)
41 assert(len(Config_PropManager().getProperties()) > 0)
42
43 # verify the property
44 prop = Config_PropManager().findProp("TestSection", "PropDouble")
45 assert(prop is not None)
46 prop.setTitle("PropTitle")
47 assert(prop.title() == "PropTitle")
48 prop.setMin("0")
49 assert(prop.min() == "0")
50 prop.setMax("100")
51 assert(prop.max() == "100")
52 prop.setType(Config_Prop.String)
53 assert(prop.type() == Config_Prop.String)