Skip to content

Commit

Permalink
[DefaultRenderer] minor whitespace improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Oct 20, 2015
1 parent 84f0455 commit bfa74e6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions netjsonconfig/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def cleanup(self, output):
# convert True to 1 and False to 0
output = output.replace('True', '1')\
.replace('False', '0')
# max 2 consecutive \n delimiters
output = output.replace('\n\n\n', '\n\n')
# if output is present
# ensure it always ends with 1 new line
if output.endswith('\n\n'):
Expand Down
3 changes: 2 additions & 1 deletion netjsonconfig/backends/openwrt/templates/default.uci
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}

{% endfor %}

{% endfor %}
{% endif %}
29 changes: 28 additions & 1 deletion tests/openwrt/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ def test_default(self):
"132/0",
"143/0"
]
},
{
"config_name": "rule",
"name": "Rule2",
"src": "wan",
"proto": "icmp",
"src_ip": "192.168.1.1/24",
"family": "ipv4",
"target": "ACCEPT",
"icmp_type": [
"130/0",
"131/0",
"132/0",
"143/0"
]
}
]
})
Expand All @@ -55,6 +70,18 @@ def test_default(self):
option src_ip 'fe80::/10'
option target 'ACCEPT'
config rule
option family 'ipv4'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option name 'Rule2'
option proto 'icmp'
option src 'wan'
option src_ip '192.168.1.1/24'
option target 'ACCEPT'
package luci
config core 'main'
Expand All @@ -78,4 +105,4 @@ def test_warning(self):
}
]
})
self.assertEqual(o.render(), 'package luci\n\n')
self.assertEqual(o.render(), 'package luci\n')

0 comments on commit bfa74e6

Please sign in to comment.