summaryrefslogtreecommitdiff
path: root/tests/test_discovery.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_discovery.py')
-rwxr-xr-xtests/test_discovery.py43
1 files changed, 43 insertions, 0 deletions
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()