diff options
Diffstat (limited to 'tests/test_discovery.py')
-rwxr-xr-x | tests/test_discovery.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 96d262e..b0de19b 100755 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import unittest -import pprint +#import pudb; pudb.set_trace() from context import haircontrol from haircontrol import discovery, data @@ -8,36 +8,33 @@ from haircontrol import discovery, data class MockInspector(object): def __init__(self, testDataPath): self.testDataPath = testDataPath + self.e = None def connect(self, e): - self.name = e.name + self.e = e def disconnect(self): - self.name = None + self.e = None def command(self, command): - if not self.name: + if not self.e: return None - mockfile = self.testDataPath + '/' + self.name + '-' + command + '.out' + mockfile = self.testDataPath + '/' + self.e.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) + ref_equipments = { 'todo': data.Equipment() } #json.load('../test-data/ref-output/equipments.json') + + self.discovery.discover_hinting_from_lldp(data.Equipment('stg2', '172.16.0.254')) + self.discovery.discover_from_root(data.Equipment('stg', '172.16.0.253')) + self.assertDictEqual(self.discovery.net.equipments, ref_equipments) if __name__ == '__main__': unittest.main() |