File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 {% for list_value in value %}
1010 list '{{ key }}' '{{ list_value }}'
1111 {% endfor %}
12+ {% elif value is boolean %}
13+ option '{{ key }}' '{{ value | int }}'
1214 {% else %}
1315 option '{{ key }}' '{{ value }}'
1416 {% endif %}
Original file line number Diff line number Diff line change @@ -16,8 +16,6 @@ def cleanup(self, output):
1616 .replace ("\n option" , "\n \t option" )
1717 .replace ("\n list" , "\n \t list" )
1818 )
19- # convert True to 1 and False to 0
20- output = output .replace ("True" , "1" ).replace ("False" , "0" )
2119 # max 2 consecutive \n delimiters
2220 output = output .replace ("\n \n \n " , "\n \n " )
2321 # if output is present
Original file line number Diff line number Diff line change 99 {% for list_value in value %}
1010 list {{ key }} '{{ list_value }}'
1111 {% endfor %}
12+ {% elif value is boolean %}
13+ option {{ key }} '{{ value | int }}'
1214 {% else %}
1315 option {{ key }} '{{ value }}'
1416 {% endif %}
Original file line number Diff line number Diff line change @@ -194,6 +194,23 @@ def test_wireless_radio_disabled_0(self):
194194 output = o .render ()
195195 self .assertIn ("option 'disabled' '0'" , output )
196196
197+ def test_render_ssid_boolean_bug (self ):
198+ """Regression test for https://github.com/openwisp/netjsonconfig/issues/383"""
199+ ssid_values = [
200+ "TrueGait Living Guest" ,
201+ "FalseGait Living Guest" ,
202+ "MyTrueNetwork" ,
203+ "True" ,
204+ "False" ,
205+ ]
206+ for ssid in ssid_values :
207+ with self .subTest (ssid = ssid ):
208+ config = deepcopy (self .config )
209+ config ["interfaces" ][2 ]["wireless" ]["ssid" ] = ssid
210+ o = OpenWisp (config )
211+ output = o .render ()
212+ self .assertIn (f"option 'ssid' '{ ssid } '" , output )
213+
197214 def test_tc_script (self ):
198215 config = deepcopy (self .config )
199216 o = OpenWisp (config )
Original file line number Diff line number Diff line change @@ -63,6 +63,23 @@ def test_render_wifi_interface(self):
6363 expected = self ._tabs (self ._wifi_uci )
6464 self .assertEqual (o .render (), expected )
6565
66+ def test_render_ssid_boolean_bug (self ):
67+ """Regression test for https://github.com/openwisp/netjsonconfig/issues/383"""
68+ ssid_values = [
69+ "TrueGait Living Guest" ,
70+ "FalseGait Living Guest" ,
71+ "MyTrueNetwork" ,
72+ "True" ,
73+ "False" ,
74+ ]
75+ for ssid in ssid_values :
76+ with self .subTest (ssid = ssid ):
77+ netjson = deepcopy (self ._wifi_netjson )
78+ netjson ["interfaces" ][0 ]["wireless" ]["ssid" ] = ssid
79+ o = OpenWrt (netjson )
80+ expected_uci = self ._wifi_uci .replace ("'MyWifiAP'" , f"'{ ssid } '" )
81+ self .assertEqual (o .render (), self ._tabs (expected_uci ))
82+
6683 def test_parse_wifi_interface (self ):
6784 o = OpenWrt (native = self ._wifi_uci )
6885 self .assertDictEqual (o .config , self ._wifi_netjson )
You can’t perform that action at this time.
0 commit comments