MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / test_osargument_value_as_json

Function test_osargument_value_as_json

python/test/test_swigjson.py:11–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10
11def test_osargument_value_as_json():
12 boolArgument = openstudio.measure.OSArgument.makeBoolArgument("bool")
13 valNotAssigned = boolArgument.valueAsJSON()
14 assert valNotAssigned is None
15 boolArgument.setValue(True)
16 val = boolArgument.valueAsJSON()
17 assert isinstance(val, bool)
18 assert val
19
20 doubleArgument = openstudio.measure.OSArgument.makeDoubleArgument("double")
21 valNotAssigned = doubleArgument.valueAsJSON()
22 assert valNotAssigned is None
23 doubleArgument.setValue(10.0)
24 val = doubleArgument.valueAsJSON()
25 assert isinstance(val, float)
26 assert val == 10.0
27
28 integerArgument = openstudio.measure.OSArgument.makeIntegerArgument("integer")
29 valNotAssigned = integerArgument.valueAsJSON()
30 assert valNotAssigned is None
31 integerArgument.setValue(10)
32 val = integerArgument.valueAsJSON()
33 assert isinstance(val, int)
34 assert val == 10
35
36 stringArgument = openstudio.measure.OSArgument.makeStringArgument("string")
37 valNotAssigned = stringArgument.valueAsJSON()
38 assert valNotAssigned is None
39 stringArgument.setValue("hello")
40 val = stringArgument.valueAsJSON()
41 assert isinstance(val, str)
42 assert val == "hello"
43
44 choices_to_display_values_map = {
45 "handle1": "choice1",
46 "handle2": "choice2",
47 }
48 choiceArgument = openstudio.measure.OSArgument.makeChoiceArgument("choice", choices_to_display_values_map)
49 valNotAssigned = choiceArgument.valueAsJSON()
50 assert valNotAssigned is None
51 choiceArgument.setValue("handle1")
52 val = choiceArgument.valueAsJSON()
53 assert isinstance(val, str)
54 assert val == "handle1"
55
56
57def test_swig_json_special_chars():

Callers

nothing calls this directly

Calls 7

makeBoolArgumentMethod · 0.80
makeDoubleArgumentMethod · 0.80
makeIntegerArgumentMethod · 0.80
makeStringArgumentMethod · 0.80
makeChoiceArgumentMethod · 0.80
valueAsJSONMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected