Exemple #1
0
 def test_parse_undef(self):
     p = OpenvpnParser(links2undef)
     data = p.json(dict=True)
     self.assertIsInstance(p.graph, networkx.Graph)
     # we expect 1 node (only the openvpn server)
     self.assertEqual(len(data['nodes']), 1)
     self.assertEqual(len(data['links']), 0)
Exemple #2
0
 def test_json_dict(self):
     p = OpenvpnParser(links2)
     data = p.json(dict=True)
     self.assertIsInstance(data, dict)
     self.assertEqual(data['type'], 'NetworkGraph')
     self.assertEqual(data['protocol'], 'OpenVPN Status Log')
     self.assertEqual(data['version'], '1')
     self.assertEqual(data['revision'], None)
     self.assertEqual(data['metric'], 'static')
     self.assertIsInstance(data['nodes'], list)
     self.assertIsInstance(data['links'], list)
     self.assertEqual(len(data['nodes']), 3)
     self.assertEqual(len(data['links']), 2)
     # check presence of labels
     labels = []
     for node in data['nodes']:
         if 'label' in node:
             labels.append(node['label'])
     self.assertEqual(len(labels), 2)
     self.assertIn('nodeA', labels)
     self.assertIn('nodeB', labels)
Exemple #3
0
 def test_parse(self):
     p = OpenvpnParser(links2)
     self.assertIsInstance(p.graph, networkx.Graph)
     self.assertEqual(p.version, '1')
     self.assertEqual(p.metric, 'static')
Exemple #4
0
 def test_empty_string(self):
     OpenvpnParser(data='')
Exemple #5
0
 def test_empty_dict(self):
     OpenvpnParser(data={})
Exemple #6
0
 def test_parse_undef(self):
     p = OpenvpnParser(links2undef)
     data = p.json(dict=True)
     self.assertIsInstance(p.graph, networkx.Graph)
     self.assertEqual(len(data['nodes']), 0)
     self.assertEqual(len(data['links']), 0)