Skip to content

Commit

Permalink
minor updates to systemtestlib and fixture data
Browse files Browse the repository at this point in the history
This commit provides a new function in the systemtestlib that will sort a
dict by its keys.  This method only sorts the first level keys and is
designed to support comparing dicts as equal in unit tests

It also adds username configuration to the running_config.text fixture

Both of these changes are to support the system and unit tests for the users
api module
  • Loading branch information
Peter Sprygada committed Apr 14, 2015
1 parent f36b82a commit 638cc9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/fixtures/running_config.text
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ no aaa authorization policy local default-role
!
username admin privilege 1 role network-admin nopassword
username eapi privilege 1 secret 5 $1$eCurfHLe$JCbuUNM7Xwy6i6/zknYha.
username sprygada privilege 1 nopassword
username test privilege 10 nopassword
username test1 privilege 1 secret 5 $1$o/po05ru$92uegC/GGu3i4MS7MH9AE0
username test2 privilege 9 role ops secret 5 $1$Kraw0Knu$dfIURYuRCxzDDcyyKnAD1/
username test3 privilege 9 role ops nopassword
!
role network-admin
10 permit command .*
Expand Down
6 changes: 6 additions & 0 deletions test/lib/systestlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#
import unittest
import random
import collections

from testlib import get_fixture

Expand All @@ -52,6 +53,11 @@ def setUp(self):
name = name.split(':')[1]
self.duts.append(pyeapi.client.connect_to(name))

def sort_dict_by_keys(self, d):
keys = sorted(d.keys())
return dict([(k, d[k]) for k in keys])


def random_interface(dut, exclude=None):
exclude = [] if exclude is None else exclude
interfaces = dut.api('interfaces')
Expand Down

0 comments on commit 638cc9c

Please sign in to comment.