summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-05-14 00:24:05 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-05-14 00:24:05 +0200
commitf362446a524efb4bd412cbb608d8704efd47d720 (patch)
tree3492b682fa5c79793258ea0559eed86e07926a77 /tests
parent08ae8abf2a62c458b9c4588e5ebd456268300965 (diff)
downloadhaircontrol-f362446a524efb4bd412cbb608d8704efd47d720.zip
haircontrol-f362446a524efb4bd412cbb608d8704efd47d720.tar.gz
haircontrol-f362446a524efb4bd412cbb608d8704efd47d720.tar.bz2
WIP : First try at getting some data from lldp and ip neigh.
Diffstat (limited to 'tests')
-rw-r--r--tests/context.py5
-rwxr-xr-xtests/test_discovery.py43
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/context.py b/tests/context.py
new file mode 100644
index 0000000..57d10fb
--- /dev/null
+++ b/tests/context.py
@@ -0,0 +1,5 @@
+import os
+import sys
+sys.path.insert(0, os.path.abspath('..'))
+
+import haircontrol
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
new file mode 100755
index 0000000..96d262e
--- /dev/null
+++ b/tests/test_discovery.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+import unittest
+import pprint
+
+from context import haircontrol
+from haircontrol import discovery, data
+
+class MockInspector(object):
+ def __init__(self, testDataPath):
+ self.testDataPath = testDataPath
+
+ def connect(self, e):
+ self.name = e.name
+
+ def disconnect(self):
+ self.name = None
+
+ def command(self, command):
+ if not self.name:
+ return None
+ mockfile = self.testDataPath + '/' + self.name + '-' + command + '.out'
+ return open(mockfile)
+
+
+class TestDiscovery(unittest.TestCase):
+
+ # http://stackoverflow.com/questions/3768895/how-to-make-a-class-json-serializable
+ def setUp(self):
+ self.discovery = discovery.Discovery(MockInspector('../test-data/input'))
+ self.maxDiff=None
+ self.ref_equipments = [] #json.load('../test-data/ref-output/equipments.json')
+
+ def test_wire_graph(self):
+ self.discovery.discover_hinting_from_lldp(data.Equipment('stg2'))
+ self.discovery.discover_from_root(data.Equipment('stg'))
+ for e in self.discovery.equipments:
+ print(e)
+ for i in e.ifaces:
+ print(i)
+ self.assertEqual(self.discovery.equipments, self.ref_equipments)
+
+if __name__ == '__main__':
+ unittest.main()