Skip to content

Commit ccd2585

Browse files
committed
[chores] Improved patch
1 parent ecdc1e5 commit ccd2585

4 files changed

Lines changed: 8 additions & 14 deletions

File tree

netjsonconfig/backends/openwisp/templates/openwrt.jinja2

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
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'
12+
{% elif value is boolean %}
13+
option '{{ key }}' '{{ value | int }}'
1714
{% else %}
1815
option '{{ key }}' '{{ value }}'
1916
{% endif %}
20-
{% endif %}
2117
{% endif %}
2218
{% endfor %}
2319

netjsonconfig/backends/openwrt/templates/openwrt.jinja2

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
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'
12+
{% elif value is boolean %}
13+
option {{ key }} '{{ value | int }}'
1714
{% else %}
1815
option {{ key }} '{{ value }}'
1916
{% endif %}
20-
{% endif %}
2117
{% endif %}
2218
{% endfor %}
2319

tests/openwisp/test_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ 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):
197+
def test_render_ssid_boolean_bug(self):
198+
"""Regression test for https://github.com/openwisp/netjsonconfig/issues/383"""
198199
ssid_values = [
199200
"TrueGait Living Guest",
200201
"FalseGait Living Guest",

tests/openwrt/test_wireless.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ 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):
66+
def test_render_ssid_boolean_bug(self):
67+
"""Regression test for https://github.com/openwisp/netjsonconfig/issues/383"""
6768
ssid_values = [
6869
"TrueGait Living Guest",
6970
"FalseGait Living Guest",

0 commit comments

Comments
 (0)