Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix peer-link parsing regex #26

Merged
merged 1 commit into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pyeapi/api/mlag.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _parse_peer_link(self, config):
dict: A dict object that is intended to be merged into the
resource dict
"""
match = re.search(r'peer-link (\w+)', config)
match = re.search(r'peer-link (\S+)', config)
value = match.group(1) if match else None
return dict(peer_link=value)

Expand Down Expand Up @@ -289,4 +289,3 @@ def instance(node):
object: An instance of Mlag
"""
return Mlag(node)

9 changes: 9 additions & 0 deletions test/system/test_api_mlag.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def test_set_peer_link_with_value(self):
self.assertTrue(result)
self.assertIn('peer-link Ethernet1', api.get_block('mlag configuration'))

def test_set_peer_link_with_value_portchannel(self):
for dut in self.duts:
dut.config(['default mlag configuration','interface Port-Channel5'])
api = dut.api('mlag')
self.assertIn('no peer-link', api.get_block('mlag configuration'))
result = dut.api('mlag').set_peer_link('Port-Channel5')
self.assertTrue(result)
self.assertIn('peer-link Port-Channel5', api.get_block('mlag configuration'))

def test_set_peer_link_with_no_value(self):
for dut in self.duts:
dut.config(['mlag configuration', 'peer-link Ethernet1'])
Expand Down
2 changes: 1 addition & 1 deletion test/system/test_api_stp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_get(self):

def test_getall(self):
for dut in self.duts:
dut.config('default interface Et1-7')
dut.config('default interface Et1-4')
result = dut.api('stp').interfaces.getall()
self.assertIsInstance(result, dict)

Expand Down