Skip to content

Commit 5985e1e

Browse files
committed
make flake happier
1 parent b7dcb32 commit 5985e1e

File tree

8 files changed

+60
-18
lines changed

8 files changed

+60
-18
lines changed

netjsonconfig/backends/airos/airos.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import re
2-
31
from six import string_types
42

5-
from .converters import *
3+
from .converters import Aaa, Bridge, Discovery, Dyndns, Ebtables, Gui, \
4+
Httpd, Igmpproxy, Iptables, Netconf, Netmode, Ntpclient, \
5+
Pwdog, Radio, Resolv, Route, Snmp, Sshd, Syslog, System, \
6+
Telnetd, Update, Users, Vlan, Wireless, Wpasupplicant
67
from .renderers import AirOS
78
from ..base.backend import BaseBackend
89
from .schema import schema
910

11+
1012
class AirOS(BaseBackend):
1113
"""
1214
AirOS backend
@@ -55,7 +57,8 @@ class AirOS(BaseBackend):
5557
def to_intermediate(self):
5658
super(AirOS, self).to_intermediate()
5759
for k, v in self.intermediate_data.items():
58-
self.intermediate_data[k] = [ x for x in flatten(intermediate_to_list(v)) if x != {}]
60+
self.intermediate_data[k] = [x for x in flatten(intermediate_to_list(v)) if x != {}]
61+
5962

6063
def flatten(xs):
6164
"""
@@ -64,7 +67,8 @@ def flatten(xs):
6467
if xs is not list:
6568
return xs
6669
else:
67-
return reduce(lambda x,y: x + flatten(y), xs, [])
70+
return reduce(lambda x, y: x + flatten(y), xs, [])
71+
6872

6973
def intermediate_to_list(configuration):
7074
"""
@@ -153,7 +157,7 @@ def intermediate_to_list(configuration):
153157
nested_key = '{key}.{subkey}'.format(key=k, subkey=sk)
154158
temp[nested_key] = sv
155159

156-
# now it is atomic, append it to
160+
# now it is atomic, append it to
157161
result.append(temp)
158162

159163
else:

netjsonconfig/backends/airos/converters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,3 +804,6 @@ def to_intermediate(self):
804804
# call either ``_station_intermediate`` or ``_access_point_intermediate``
805805
# and return the result
806806
return getattr(self, '_%s_intermediate' % head['wireless']['mode'])(original)
807+
808+
809+
__all__ = []

netjsonconfig/backends/airos/schema.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
from ...schema import DEFAULT_FILE_MODE # noqa - backward compatibility
66
from ...utils import merge_config
77

8+
9+
def merge_list(schema_list):
10+
schema = default_schema
11+
for s in schema_list:
12+
schema = merge_config(schema, s)
13+
return schema
14+
15+
816
"""
917
This defines a new property in the ``Interface``.
1018
@@ -30,13 +38,13 @@
3038
}
3139
}
3240

41+
3342
"""
3443
This schema defines a new property for netjson
3544
3645
As the antenna can be in ``bridge`` or ``router`` mode
3746
this mode can be selected from this property
3847
"""
39-
4048
netmode_schema = {
4149
"type": "object",
4250
"properties": {
@@ -51,6 +59,7 @@
5159
},
5260
}
5361

62+
5463
"""
5564
This schema override the possible encryption for AirOS from the default schema
5665
"""
@@ -88,9 +97,11 @@
8897
}
8998

9099

91-
schema = merge_config(
100+
schema = merge_list([
92101
default_schema,
93102
netconf_schema,
94103
netmode_schema,
95104
wpasupplicant_schema,
96-
)
105+
])
106+
107+
__all__ = [schema]

tests/airos/dummy.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from netjsonconfig import AirOS
22

3-
from netjsonconfig.backends.airos.converters import *
3+
from netjsoncongig.backends.airos.converters import Aaa, Bridge, Discovery, Dyndns, Ebtables, Gui, \
4+
Httpd, Igmpproxy, Iptables, Netconf, Netmode, Ntpclient, \
5+
Pwdog, Radio, Resolv, Route, Snmp, Sshd, Syslog, System, \
6+
Telnetd, Update, Users, Vlan, Wireless, Wpasupplicant
47

58
from unittest import TestCase
69

@@ -66,6 +69,15 @@ class DyndnsAirOS(AirOS):
6669
]
6770

6871

72+
class EbtablesAirOS(AirOS):
73+
"""
74+
Mock backend with converter for ebtables
75+
"""
76+
converters = [
77+
Ebtables,
78+
]
79+
80+
6981
class GuiAirOS(AirOS):
7082
"""
7183
Mock backend with converter for web interface settings
@@ -84,6 +96,24 @@ class HttpdAirOS(AirOS):
8496
]
8597

8698

99+
class Igmpproxy(AirOS):
100+
"""
101+
Mock backend with converter for igmpproxy
102+
"""
103+
converters = [
104+
Igmpproxy,
105+
]
106+
107+
108+
class IptablesAirOS(AirOS):
109+
"""
110+
Mock backend with converter for iptables
111+
"""
112+
converters = [
113+
Iptables,
114+
]
115+
116+
87117
class NetconfAirOS(AirOS):
88118
"""
89119
Mock backend with converter for network configuration

tests/airos/test_bridge.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from netjsonconfig.backends.airos.converters import *
2-
31
from .dummy import BridgeAirOS, ConverterTest
42

53

tests/airos/test_discovery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ def test_discovery_key(self):
1919
},
2020
]
2121

22-
2322
self.assertEqualConfig(o.intermediate_data['discovery'], expected)

tests/airos/test_netconf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def test_inactive_interface(self):
7878
},
7979
]
8080

81-
8281
self.assertEqualConfig(o.intermediate_data['netconf'], expected)
8382

8483
def test_vlan(self):
@@ -143,7 +142,7 @@ def test_management_vlan(self):
143142
'status': 'enabled',
144143
},
145144
]
146-
145+
147146
self.assertEqualConfig(o.intermediate_data['netconf'], expected)
148147

149148
def test_access_point(self):
@@ -445,7 +444,7 @@ def test_other(self):
445444
'status': 'enabled',
446445
},
447446
]
448-
447+
449448
self.assertEqualConfig(o.intermediate_data['netconf'], expected)
450449

451450
def test_more_interfaces(self):

tests/airos/test_netmode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from unittest import skip
21
from .dummy import NetmodeAirOS, ConverterTest
32

43

@@ -48,5 +47,4 @@ def test_router(self):
4847
},
4948
]
5049

51-
5250
self.assertEqualConfig(o.intermediate_data['netmode'], expected)

0 commit comments

Comments
 (0)