Skip to content

Commit

Permalink
[openwrt] Removed automatic timezone #87
Browse files Browse the repository at this point in the history
Closes #87
  • Loading branch information
nemesifier committed Jul 5, 2017
1 parent 69f9ba5 commit cda5e9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 3 additions & 4 deletions netjsonconfig/backends/openwrt/converters/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ def to_intermediate_loop(self, block, result, index=None):
def __intermediate_system(self, general):
if not general:
return None
timezone_human = general.get('timezone', 'UTC')
timezone_value = timezones[timezone_human]
general.update({
'.type': 'system',
'.name': general.pop('id', 'system'),
'hostname': general.get('hostname', 'OpenWRT'),
'timezone': timezone_value,
'zonename': timezone_human,
})
if 'timezone' in general:
general['zonename'] = general['timezone']
general['timezone'] = timezones[general['timezone']]
return [self.sorted_dict(general)]

def __intermediate_ula(self, general):
Expand Down
16 changes: 16 additions & 0 deletions tests/openwrt/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ def test_parse_system(self):
o = OpenWrt(native=self._system_uci)
self.assertDictEqual(o.config, self._system_netjson)

_system_simple_netjson = {"general": {"hostname": "test-system"}}
_system_simple_uci = """package system
config system 'system'
option hostname 'test-system'
"""

def test_render_system_without_timezone(self):
o = OpenWrt(self._system_simple_netjson)
expected = self._tabs(self._system_simple_uci)
self.assertEqual(o.render(), expected)

def test_parse_system_without_timezone(self):
o = OpenWrt(native=self._system_simple_uci)
self.assertEqual(o.config, self._system_simple_netjson)

_system_id_netjson = {
"general": {
"id": "arbitrary",
Expand Down

0 comments on commit cda5e9d

Please sign in to comment.