File tree Expand file tree Collapse file tree
netjsonconfig/backends/openwrt Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,8 +16,10 @@ 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" )
19+ import re
20+ # convert 'True' to '1' and 'False' to '0', but only on whole words bounded by quotes e.g. 'True' -> '1'
21+ output = re .sub (r"'True'" , "'1'" , output )
22+ output = re .sub (r"'False'" , "'0'" , output )
2123 # max 2 consecutive \n delimiters
2224 output = output .replace ("\n \n \n " , "\n \n " )
2325 # if output is present
Original file line number Diff line number Diff line change @@ -63,6 +63,21 @@ 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_true_ssid (self ):
67+ netjson = deepcopy (self ._wifi_netjson )
68+ netjson ["interfaces" ][0 ]["wireless" ]["ssid" ] = "TrueGait Living Guest"
69+ o = OpenWrt (netjson )
70+ expected_uci = self ._wifi_uci .replace ("'MyWifiAP'" , "'TrueGait Living Guest'" )
71+ self .assertEqual (o .render (), self ._tabs (expected_uci ))
72+
73+ def test_render_wifi_issue_250_false_ssid (self ):
74+ netjson = deepcopy (self ._wifi_netjson )
75+ netjson ["interfaces" ][0 ]["wireless" ]["ssid" ] = "FalseGait Living Guest"
76+ o = OpenWrt (netjson )
77+ expected_uci = self ._wifi_uci .replace ("'MyWifiAP'" , "'FalseGait Living Guest'" )
78+ self .assertEqual (o .render (), self ._tabs (expected_uci ))
79+
80+
6681 def test_parse_wifi_interface (self ):
6782 o = OpenWrt (native = self ._wifi_uci )
6883 self .assertDictEqual (o .config , self ._wifi_netjson )
You can’t perform that action at this time.
0 commit comments