From d6d318e6b8120bc09ed45b6d92487af6864bbe2f Mon Sep 17 00:00:00 2001 From: Philip DiLeo Date: Tue, 20 Oct 2015 15:46:21 -0400 Subject: [PATCH] Add more unit tests --- pyeapi/api/interfaces.py | 8 +------- test/unit/test_api_interfaces.py | 4 ++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pyeapi/api/interfaces.py b/pyeapi/api/interfaces.py index 650fd63..73ad159 100644 --- a/pyeapi/api/interfaces.py +++ b/pyeapi/api/interfaces.py @@ -108,7 +108,7 @@ def getall(self): for name in interfaces_re.findall(self.config): interface = self.get(name) if interface: - response[name] = interface + response['name'] = interface return response def __getattr__(self, name): @@ -172,7 +172,6 @@ def get(self, name): resource.update(self._parse_description(config)) return resource - def _parse_shutdown(self, config): """Scans the specified config block and returns the shutdown value @@ -334,7 +333,6 @@ def get(self, name): resource.update(self._parse_flowcontrol_receive(config)) return resource - def _parse_sflow(self, config): """Scans the specified config block and returns the sflow value @@ -383,7 +381,6 @@ def _parse_flowcontrol_receive(self, config): value = match.group(1) return dict(flowcontrol_receive=value) - def create(self, name): """Creating Ethernet interfaces is currently not supported @@ -549,7 +546,6 @@ def _parse_minimum_links(self, config): value = int(match.group(1)) return dict(minimum_links=value) - def get_lacp_mode(self, name): """Returns the LACP mode for the specified Port-Channel interface @@ -571,8 +567,6 @@ def get_lacp_mode(self, name): self.get_block('^interface %s' % member)) return match.group('value') - - def get_members(self, name): """Returns the member interfaces for the specified Port-Channel diff --git a/test/unit/test_api_interfaces.py b/test/unit/test_api_interfaces.py index 5cd01af..9a7f1bb 100644 --- a/test/unit/test_api_interfaces.py +++ b/test/unit/test_api_interfaces.py @@ -77,6 +77,10 @@ def test_get_interface_ethernet(self): result = self.instance.get('Ethernet1') self.assertEqual(result['type'], 'ethernet') + def test_get_invalid_interface(self): + result = self.instance.get('Foo1') + self.assertEqual(result, None) + def test_proxy_method_success(self): result = self.instance.set_sflow('Ethernet1', True) self.assertTrue(result)