def test_json_string(self): p = CnmlParser(cnml1) data = p.json() self.assertIsInstance(data, six.string_types) self.assertIn('NetworkGraph', data) self.assertIn('protocol', data) self.assertIn('version', data) self.assertIn('revision', data) self.assertIn('metric', data) self.assertIn('null', data) self.assertIn('links', data) self.assertIn('nodes', data)
def test_json_string(self): p = CnmlParser(cnml1) data = p.json() self.assertIsInstance(data, six.string_types) self.assertIn("NetworkGraph", data) self.assertIn("protocol", data) self.assertIn("version", data) self.assertIn("revision", data) self.assertIn("metric", data) self.assertIn("null", data) self.assertIn("links", data) self.assertIn("nodes", data)
def test_json_dict(self): p = CnmlParser(cnml1) data = p.json(dict=True) self.assertIsInstance(data, dict) self.assertEqual(data['type'], 'NetworkGraph') self.assertEqual(data['protocol'], 'static') self.assertEqual(data['version'], None) self.assertEqual(data['revision'], None) self.assertEqual(data['metric'], None) self.assertIsInstance(data['nodes'], list) self.assertIsInstance(data['links'], list) self.assertEqual(len(data['nodes']), 5) self.assertEqual(len(data['links']), 3)
def test_json_dict(self): p = CnmlParser(cnml1) data = p.json(dict=True) self.assertIsInstance(data, dict) self.assertEqual(data["type"], "NetworkGraph") self.assertEqual(data["protocol"], "static") self.assertEqual(data["version"], None) self.assertEqual(data["revision"], None) self.assertEqual(data["metric"], None) self.assertIsInstance(data["nodes"], list) self.assertIsInstance(data["links"], list) self.assertEqual(len(data["nodes"]), 5) self.assertEqual(len(data["links"]), 3)