diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-10 16:47:07 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-10 16:47:07 +0000 |
commit | 6a61816c47cbba1d2438a9d1d963cb9b23cca898 (patch) | |
tree | 9ed36b6c17a1715d6a421d9bc059a36c1787d5d4 /db/db.py | |
parent | 8b317afd084eb8a6a8f9c1bd3a4e4a33b3e8fb98 (diff) |
Added trivial self-test if run directly
Just dump the contents of the current database
Change-Id: I7e1c250d45a2dea8d188951f36cac4892f42f2ed
Diffstat (limited to 'db/db.py')
-rw-r--r-- | db/db.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -20,7 +20,13 @@ import psycopg2 import psycopg2.extras -import datetime +import datetime, os, sys + +if __name__ == '__main__': + vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) + sys.path.insert(0, vlandpath) + sys.path.insert(0, "%s/.." % vlandpath) + from errors import CriticalError, InputError class VlanDB: @@ -540,3 +546,16 @@ class VlanDB: def all_vlans(self): return self._dump_table("vlan") +if __name__ == '__main__': + db = VlanDB() + switches = db.all_switches() + print 'The DB knows about %d switch(es)' % len(switches) + print switches + ports = db.all_ports() + print 'The DB knows about %d port(s)' % len(ports) + print ports + vlans = db.all_vlans() + print 'The DB knows about %d vlan(s)' % len(vlans) + print vlans + + |