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+ {% else %}
13+ {% if value is sameas true %}
14+ option '{{ key }}' '1'
15+ {% elif value is sameas false %}
16+ option '{{ key }}' '0'
1217 {% else %}
1318 option '{{ key }}' '{{ value }}'
1419 {% endif %}
20+ {% endif %}
1521 {% endif %}
1622 {% endfor %}
1723
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+ {% else %}
13+ {% if value is sameas true %}
14+ option {{ key }} '1'
15+ {% elif value is sameas false %}
16+ option {{ key }} '0'
1217 {% else %}
1318 option {{ key }} '{{ value }}'
1419 {% endif %}
20+ {% endif %}
1521 {% endif %}
1622 {% endfor %}
1723
Original file line number Diff line number Diff line change @@ -194,6 +194,22 @@ def test_wireless_radio_disabled_0(self):
194194 output = o .render ()
195195 self .assertIn ("option 'disabled' '0'" , output )
196196
197+ def test_render_wifi_issue_250_ssid_variants (self ):
198+ ssid_values = [
199+ "TrueGait Living Guest" ,
200+ "FalseGait Living Guest" ,
201+ "MyTrueNetwork" ,
202+ "True" ,
203+ "False" ,
204+ ]
205+ for ssid in ssid_values :
206+ with self .subTest (ssid = ssid ):
207+ config = deepcopy (self .config )
208+ config ["interfaces" ][2 ]["wireless" ]["ssid" ] = ssid
209+ o = OpenWisp (config )
210+ output = o .render ()
211+ self .assertIn (f"option 'ssid' '{ ssid } '" , output )
212+
197213 def test_tc_script (self ):
198214 config = deepcopy (self .config )
199215 o = OpenWisp (config )
Original file line number Diff line number Diff line change @@ -63,6 +63,22 @@ def test_render_wifi_interface(self):
6363 expected = self ._tabs (self ._wifi_uci )
6464 self .assertEqual (o .render (), expected )
6565
66+ def test_render_wifi_issue_250_ssid_variants (self ):
67+ ssid_values = [
68+ "TrueGait Living Guest" ,
69+ "FalseGait Living Guest" ,
70+ "MyTrueNetwork" ,
71+ "True" ,
72+ "False" ,
73+ ]
74+ for ssid in ssid_values :
75+ with self .subTest (ssid = ssid ):
76+ netjson = deepcopy (self ._wifi_netjson )
77+ netjson ["interfaces" ][0 ]["wireless" ]["ssid" ] = ssid
78+ o = OpenWrt (netjson )
79+ expected_uci = self ._wifi_uci .replace ("'MyWifiAP'" , f"'{ ssid } '" )
80+ self .assertEqual (o .render (), self ._tabs (expected_uci ))
81+
6682 def test_parse_wifi_interface (self ):
6783 o = OpenWrt (native = self ._wifi_uci )
6884 self .assertDictEqual (o .config , self ._wifi_netjson )
You can’t perform that action at this time.
0 commit comments