Skip to content

Commit f24f705

Browse files
authored
Merge pull request #1886 from anarkiwi/master
pylint.
2 parents bb3a9d9 + 18c6728 commit f24f705

File tree

2 files changed

+44
-19
lines changed

2 files changed

+44
-19
lines changed

tests/test_config.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def tearDown(self):
2626
shutil.rmtree(self.tmpdir)
2727

2828
def conf_file_name(self):
29+
"""Return path to test config file in test directory."""
2930
return os.path.join(self.tmpdir, 'faucet.yaml')
3031

3132
def create_config_file(self, config):
@@ -45,7 +46,7 @@ def run_function_with_config(self, config, function, before_function=None):
4546
before_function()
4647
try:
4748
function(conf_file, LOGNAME)
48-
except cp.InvalidConfigError as err:
49+
except cp.InvalidConfigError as _err:
4950
return False
5051
return True
5152

@@ -523,6 +524,7 @@ def test_invalid_interfaces(self):
523524
self.check_config_failure(config, cp.dp_parser)
524525

525526
def test_unresolved_mirror_ports(self):
527+
"""Test invalid mirror port name."""
526528
config = """
527529
vlans:
528530
office:
@@ -562,6 +564,7 @@ def test_resolved_mirror_port(self):
562564
self.check_config_success(config, cp.dp_parser)
563565

564566
def test_vlans_on_mirror_ports(self):
567+
"""Test invalid VLANs configured on a mirror port."""
565568
config = """
566569
vlans:
567570
office:
@@ -579,6 +582,7 @@ def test_vlans_on_mirror_ports(self):
579582
self.check_config_failure(config, cp.dp_parser)
580583

581584
def test_unresolved_output_ports(self):
585+
"""Test invalid output port name."""
582586
config = """
583587
vlans:
584588
office:
@@ -601,6 +605,7 @@ def test_unresolved_output_ports(self):
601605
self.check_config_failure(config, cp.dp_parser)
602606

603607
def test_unknown_output_ports(self):
608+
"""Test invalid mirror ACL port."""
604609
config = """
605610
vlans:
606611
office:
@@ -674,6 +679,7 @@ def test_single_range_valid_config(self):
674679
self.assertEqual(len(dp.ports), 1)
675680

676681
def test_port_range_invalid_config(self):
682+
"""Test invalid characters used in interface_ranges."""
677683
config = """
678684
vlans:
679685
office:
@@ -688,6 +694,7 @@ def test_port_range_invalid_config(self):
688694
self.check_config_failure(config, cp.dp_parser)
689695

690696
def test_acl_no_actions(self):
697+
"""Test ACL with invalid actions section."""
691698
config = """
692699
acls:
693700
office-vlan-protect:
@@ -709,6 +716,7 @@ def test_acl_no_actions(self):
709716
self.check_config_failure(config, cp.dp_parser)
710717

711718
def test_acl_invalid_ipv4(self):
719+
"""Test invalid IPv4 address in ACL."""
712720
config = """
713721
acls:
714722
office-vlan-protect:
@@ -730,6 +738,7 @@ def test_acl_invalid_ipv4(self):
730738
self.check_config_failure(config, cp.dp_parser)
731739

732740
def test_acl_invalid_ipv6(self):
741+
"""Test invalid IPv6 address in ACL."""
733742
config = """
734743
acls:
735744
office-vlan-protect:
@@ -751,6 +760,7 @@ def test_acl_invalid_ipv6(self):
751760
self.check_config_failure(config, cp.dp_parser)
752761

753762
def test_acl_invalid_mask(self):
763+
"""Test invalid IPv4 mask in ACL."""
754764
config = """
755765
acls:
756766
office-vlan-protect:
@@ -772,6 +782,7 @@ def test_acl_invalid_mask(self):
772782
self.check_config_failure(config, cp.dp_parser)
773783

774784
def test_acl_invalid_udp_port(self):
785+
"""Test invalid UDP port in ACL."""
775786
config = """
776787
acls:
777788
access-port-protect:
@@ -792,6 +803,7 @@ def test_acl_invalid_udp_port(self):
792803
self.check_config_failure(config, cp.dp_parser)
793804

794805
def test_acl_invalid_rule_name(self):
806+
"""Test invalid name for rule in ACL."""
795807
config = """
796808
acls:
797809
access-port-protect:
@@ -812,6 +824,7 @@ def test_acl_invalid_rule_name(self):
812824
self.check_config_failure(config, cp.dp_parser)
813825

814826
def test_acl_and_acls_vlan_invalid(self):
827+
"""Test cannot have acl_in and acls_in together."""
815828
config = """
816829
acls:
817830
access-port-protect:
@@ -835,7 +848,7 @@ def test_acl_and_acls_vlan_invalid(self):
835848
"""
836849
self.check_config_failure(config, cp.dp_parser)
837850

838-
def test_inconsistent_acl_exact_match(self):
851+
def test_inconsistent_exact_match(self):
839852
"""Test that ACLs have consistent exact_match."""
840853
config = """
841854
acls:
@@ -887,6 +900,7 @@ def test_acl_and_acls_port_invalid(self):
887900
self.check_config_failure(config, cp.dp_parser)
888901

889902
def test_acls_vlan_valid(self):
903+
"""Test ACLs can be combined on VLAN."""
890904
config = """
891905
acls:
892906
access-port-protect:
@@ -910,6 +924,7 @@ def test_acls_vlan_valid(self):
910924
self.check_config_success(config, cp.dp_parser)
911925

912926
def test_acls_port_valid(self):
927+
"""Test ACLs can be combined on a port."""
913928
config = """
914929
acls:
915930
access-port-protect:
@@ -933,10 +948,12 @@ def test_acls_port_valid(self):
933948
self.check_config_success(config, cp.dp_parser)
934949

935950
def test_invalid_char(self):
951+
"""Test config file with invalid characters."""
936952
config = b'\x63\xe1'
937953
self.check_config_failure(config, cp.dp_parser)
938954

939955
def test_perm_denied(self):
956+
"""Test config file has no read permission."""
940957

941958
def unreadable():
942959
"""Make config unreadable."""
@@ -946,6 +963,7 @@ def unreadable():
946963
self.check_config_failure(config, cp.dp_parser, before_function=unreadable)
947964

948965
def test_missing_route_config(self):
966+
"""Test missing IP gateway for route."""
949967
config = """
950968
vlans:
951969
office:
@@ -964,6 +982,7 @@ def test_missing_route_config(self):
964982
self.check_config_failure(config, cp.dp_parser)
965983

966984
def test_invalid_dp_conf(self):
985+
"""Test invalid DP header config."""
967986
config = """
968987
vlans:
969988
office:
@@ -1034,6 +1053,7 @@ def test_invalid_key(self):
10341053
self.check_config_failure(config, cp.dp_parser)
10351054

10361055
def test_invalid_acl_formation(self):
1056+
"""Test missing ACL name."""
10371057
config = """
10381058
acls:
10391059
# office-vlan-protect:
@@ -1643,6 +1663,7 @@ def test_unknown_port_key(self):
16431663
self.check_config_failure(config, cp.dp_parser)
16441664

16451665
def test_meter_config(self):
1666+
"""Test valid meter config."""
16461667
config = """
16471668
meters:
16481669
lossymeter:

tests/test_valve.py

+21-17
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ class ValveTestBase(unittest.TestCase):
152152
system_name: "faucet"
153153
port_descr: "first_port"
154154
loop_protect: True
155+
receive_lldp: True
156+
max_hosts: 1
155157
p2:
156158
number: 2
157159
native_vlan: v200
@@ -370,23 +372,25 @@ def packet_outs_from_flows(flows):
370372

371373
def learn_hosts(self):
372374
"""Learn some hosts."""
373-
self.rcv_packet(1, 0x100, {
374-
'eth_src': self.P1_V100_MAC,
375-
'eth_dst': self.UNKNOWN_MAC,
376-
'ipv4_src': '10.0.0.1',
377-
'ipv4_dst': '10.0.0.2'})
378-
self.rcv_packet(2, 0x200, {
379-
'eth_src': self.P2_V200_MAC,
380-
'eth_dst': self.P3_V200_MAC,
381-
'ipv4_src': '10.0.0.2',
382-
'ipv4_dst': '10.0.0.3',
383-
'vid': 0x200})
384-
self.rcv_packet(3, 0x200, {
385-
'eth_src': self.P3_V200_MAC,
386-
'eth_dst': self.P2_V200_MAC,
387-
'ipv4_src': '10.0.0.3',
388-
'ipv4_dst': '10.0.0.4',
389-
'vid': 0x200})
375+
# TODO: verify learn caching.
376+
for _ in range(2):
377+
self.rcv_packet(1, 0x100, {
378+
'eth_src': self.P1_V100_MAC,
379+
'eth_dst': self.UNKNOWN_MAC,
380+
'ipv4_src': '10.0.0.1',
381+
'ipv4_dst': '10.0.0.2'})
382+
self.rcv_packet(2, 0x200, {
383+
'eth_src': self.P2_V200_MAC,
384+
'eth_dst': self.P3_V200_MAC,
385+
'ipv4_src': '10.0.0.2',
386+
'ipv4_dst': '10.0.0.3',
387+
'vid': 0x200})
388+
self.rcv_packet(3, 0x200, {
389+
'eth_src': self.P3_V200_MAC,
390+
'eth_dst': self.P2_V200_MAC,
391+
'ipv4_src': '10.0.0.3',
392+
'ipv4_dst': '10.0.0.4',
393+
'vid': 0x200})
390394

391395
def verify_flooding(self, matches):
392396
"""Verify flooding for a packet, depending on the DP implementation."""

0 commit comments

Comments
 (0)