Commit 19c8c91c authored by Benoit GAUZERE's avatar Benoit GAUZERE

Add of first unit tests for graphfiles.py

parent 5033c344
import unittest
class TestGraphFilesMethods(unittest.TestCase):
def test_loadCT(self):
from pygraph.utils.graphfiles import loadCT
g = loadCT('./test.ct')
self.assertEqual(g.number_of_nodes(), 104)
self.assertEqual(g.number_of_edges(), 109)
self.assertEqual(len(g.nodes()), 104)
self.assertEqual(g.graph['filename'], 'test.ct')
self.assertEqual(g.nodes[1]['atom'], 'N')
self.assertEqual(g[30][102]['bond_type'], '1')
self.assertEqual(g[30][102]['bond_type'], g[102][30]['bond_type'])
# test if an edge does *not* exists
def test_loadGXL(self):
from pygraph.utils.graphfiles import loadGXL
g = loadGXL('./test.gxl')
self.assertEqual(g.number_of_nodes(), 104)
self.assertEqual(g.number_of_edges(), 109)
self.assertEqual(len(g.nodes()), 104)
self.assertEqual(g.graph['filename'], 'test.gxl')
self.assertEqual(g.nodes[1]['chem'], 'N')
self.assertEqual(g[30][102]['valence'], '1')
self.assertEqual(g[30][102]['valence'], g[102][30]['valence'])
# test if an edge does *not* exists
def test_saveGXL(self):
from pygraph.utils.graphfiles import loadCT,saveGXL, loadGXL
g = loadCT('./test.ct')
saveGXL(g,'tmp.gxl')
g2 = loadGXL('tmp.gxl')
self.assertEqual(g.number_of_nodes(), g2.number_of_nodes())
self.assertEqual(g.number_of_edges(), g2.number_of_edges())
if __name__ == '__main__':
import sys
import pathlib
sys.path.insert(0, "../")
import networkx
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment