Skip to content

Commit

Permalink
Test raises (#83)
Browse files Browse the repository at this point in the history
* Add tests for raises

* Add input for tests for raises
  • Loading branch information
martinateruzzi authored May 21, 2021
1 parent 87d6a87 commit 9be1c57
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/TOY_graph_one_node.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mark,father_condition,father_mark,area,perturbation_resistant,init_status,description,type,weight,initial_service
"1","ORPHAN","NULL","area1",0,,,"SOURCE",1.0,1.0
77 changes: 77 additions & 0 deletions tests/test_integer_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,80 @@ def test_clear_non_existing_attribute(self):

with self.assertRaises(ValueError):
g.clear_data('non_existing_attribute')

def test_ValueError_global_efficiency(self):
"""
The following test the error for trying to compute global efficiency
for a graph of one node.
"""
g = GeneralGraph()
g.load("tests/TOY_graph_one_node.csv")

with self.assertRaises(ValueError):
g.global_efficiency

def test_ValueError_nodal_efficiency(self):
"""
The following test the error for trying to compute nodal efficiency
for a graph of one node.
"""
g = GeneralGraph()
g.load("tests/TOY_graph_one_node.csv")

with self.assertRaises(ValueError):
g.nodal_efficiency

def test_ValueError_closeness_centrality(self):
"""
The following test the error for trying to compute closeness centrality
for a graph of one node.
"""
g = GeneralGraph()
g.load("tests/TOY_graph_one_node.csv")

with self.assertRaises(ValueError):
g.closeness_centrality

def test_ValueError_degree_centrality(self):
"""
The following test the error for trying to compute degree centrality
for a graph of one node.
"""
g = GeneralGraph()
g.load("tests/TOY_graph_one_node.csv")

with self.assertRaises(ValueError):
g.degree_centrality

def test_ValueError_indegree_centrality(self):
"""
The following test the error for trying to compute indegree centrality
for a graph of one node.
"""
g = GeneralGraph()
g.load("tests/TOY_graph_one_node.csv")

with self.assertRaises(ValueError):
g.indegree_centrality

def test_ValueError_outdegree_centrality(self):
"""
The following test the error for trying to compute outdegree centrality
for a graph of one node.
"""
g = GeneralGraph()
g.load("tests/TOY_graph_one_node.csv")

with self.assertRaises(ValueError):
g.outdegree_centrality

def test_ValueError_print_graph(self):
"""
The following test the error for trying to print the graph with fixed
nodes without providing initial positions.
"""
g = GeneralGraph()
g.load("tests/TOY_graph.csv")

with self.assertRaises(ValueError):
g.print_graph(fixed_nodes=list(g))

0 comments on commit 9be1c57

Please sign in to comment.