11import unittest
2- from gitnet import gn_multigraph
2+ from gitnet import multigraph
33
44
55class CollapseEdgesTest (unittest .TestCase ):
6- """Tests for the collapse_edges() method within gn_multigraph .py"""
6+ """Tests for the collapse_edges() method within multigraph .py"""
77 # A simple graph with weights
8- mgw = gn_multigraph .MultiGraphPlus ()
8+ mgw = multigraph .MultiGraphPlus ()
99 mgw .add_edge (1 , 2 , weight = 3 )
1010 mgw .add_edge (1 , 2 , weight = 2 )
1111 mgw .add_edge (2 , 3 , weight = 4 )
1212
1313 # A graph with no weights, but other similar attributes
14- now = gn_multigraph .MultiGraphPlus ()
14+ now = multigraph .MultiGraphPlus ()
1515 now .add_edge ('Alice' , 'file01' , type = 'commit' , date = 'Jan 3' , changed_lines = [5 ,18 ,38 ,44 ])
1616 now .add_edge ('file01' , 'Alice' , type = 'commit' , date = 'Jan 5' , changed_lines = [3 ,5 ,23 ,67 ])
1717 now .add_edge ('file01' , 'Bob' , type = 'issue' , date = 'Jan 16' , importance = 'high' )
1818
1919 # A graph whose edges have weights and other different attributes
20- diff = gn_multigraph .MultiGraphPlus ()
20+ diff = multigraph .MultiGraphPlus ()
2121 diff .add_edge ('Charlie' , 'file02' , weight = 2 , type = 'commit' , date = 'Jan 1' , changed_lines = [1 , 2 ])
2222 diff .add_edge ('Charlie' , 'file02' , weight = 1 , type = 'issue' , date = 'Jan 2' , importance = 'high' )
2323 diff .add_edge ('Charlie' , 'file02' , weight = 4 , type = 'review' , date = 'Jan 5' , status = 'PASS' )
@@ -33,7 +33,7 @@ def test_simple(self):
3333 """When sum_weights==False, or isn't provided, are weights calculated by adding number of edges?"""
3434 # sum_weights is made explicit
3535 sumwf_explicit = self .mgw .collapse_edges (sum_weights = False )
36- self .assertIsInstance (sumwf_explicit , gn_multigraph .MultiGraphPlus )
36+ self .assertIsInstance (sumwf_explicit , multigraph .MultiGraphPlus )
3737 self .assertEqual (sumwf_explicit .edge [1 ][2 ][0 ]['weight' ], 2 )
3838 self .assertEqual (sumwf_explicit .edge [2 ][3 ][0 ]['weight' ], 1 )
3939 self .assertEqual (len (sumwf_explicit .edge [1 ]), 1 )
@@ -42,7 +42,7 @@ def test_simple(self):
4242
4343 # sum_weights is left to the default
4444 sumwf = self .mgw .collapse_edges ()
45- self .assertIsInstance (sumwf , gn_multigraph .MultiGraphPlus )
45+ self .assertIsInstance (sumwf , multigraph .MultiGraphPlus )
4646 self .assertEqual (sumwf .edge [1 ][2 ][0 ]['weight' ], 2 )
4747 self .assertEqual (sumwf .edge [2 ][3 ][0 ]['weight' ], 1 )
4848 self .assertEqual (len (sumwf .edge [1 ]), 1 )
@@ -52,7 +52,7 @@ def test_simple(self):
5252 def test_simple_sum_weights (self ):
5353 """When sum_weights==True, are weights added?"""
5454 sumwt = self .mgw .collapse_edges (sum_weights = True )
55- self .assertIsInstance (sumwt , gn_multigraph .MultiGraphPlus )
55+ self .assertIsInstance (sumwt , multigraph .MultiGraphPlus )
5656 self .assertEqual (sumwt .edge [1 ][2 ][0 ]['weight' ], 5 )
5757 self .assertEqual (sumwt .edge [2 ][3 ][0 ]['weight' ], 4 )
5858 self .assertEqual (len (sumwt .edge [1 ]), 1 )
@@ -63,15 +63,15 @@ def test_no_weight(self):
6363 """Is the absence of a weight attribute handled correctly? (Default to 1)?"""
6464 # Summing the weights
6565 sum = self .now .collapse_edges (sum_weights = True )
66- self .assertIsInstance (sum , gn_multigraph .MultiGraphPlus )
66+ self .assertIsInstance (sum , multigraph .MultiGraphPlus )
6767 self .assertEqual (sum .edge ['Alice' ]['file01' ][0 ]['weight' ], 2 )
6868 self .assertEqual (sum .edge ['file01' ]['Bob' ][0 ]['weight' ], 1 )
6969 self .assertEqual (len (sum .edge ['Alice' ]), 1 )
7070 self .assertEqual (len (sum .edge ['file01' ]), 2 )
7171 self .assertEqual (len (sum .edge ['Bob' ]), 1 )
7272 # Not summing weights
7373 nosum = self .now .collapse_edges ()
74- self .assertIsInstance (nosum , gn_multigraph .MultiGraphPlus )
74+ self .assertIsInstance (nosum , multigraph .MultiGraphPlus )
7575 self .assertEqual (nosum .edge ['Alice' ]['file01' ][0 ]['weight' ], 2 )
7676 self .assertEqual (nosum .edge ['file01' ]['Bob' ][0 ]['weight' ], 1 )
7777 self .assertEqual (len (nosum .edge ['Alice' ]), 1 )
@@ -84,20 +84,20 @@ def test_some_weight(self):
8484 mgw .add_edge (2 ,3 ) # Add non-weighted edge
8585 # Sum weights
8686 somew_sum = mgw .collapse_edges (sum_weights = True )
87- self .assertIsInstance (somew_sum , gn_multigraph .MultiGraphPlus )
87+ self .assertIsInstance (somew_sum , multigraph .MultiGraphPlus )
8888 self .assertEqual (somew_sum .edge [1 ][2 ][0 ]['weight' ],5 )
8989 self .assertEqual (somew_sum .edge [2 ][3 ][0 ]['weight' ],5 )
9090
9191 # Don't sum weights
9292 somew_nosum = mgw .collapse_edges (sum_weights = False )
93- self .assertIsInstance (somew_nosum , gn_multigraph .MultiGraphPlus )
93+ self .assertIsInstance (somew_nosum , multigraph .MultiGraphPlus )
9494 self .assertEqual (somew_nosum .edge [1 ][2 ][0 ]['weight' ], 2 )
9595 self .assertEqual (somew_nosum .edge [2 ][3 ][0 ]['weight' ], 2 )
9696
9797 def test_eattr (self ):
9898 """Are edge attributes retained?"""
9999 mg = self .now .collapse_edges ()
100- self .assertIsInstance (mg , gn_multigraph .MultiGraphPlus )
100+ self .assertIsInstance (mg , multigraph .MultiGraphPlus )
101101 # Looking at Alice, contains a list attribute
102102 self .assertIsInstance (mg .edge ['Alice' ], dict )
103103 AD = {'file01' : {0 : {'weight' : 2 ,
@@ -121,7 +121,7 @@ def test_diff_attr(self):
121121 """Are edge attributes retained properly, even when they aren't the same?"""
122122 # Sum the weights
123123 diff_attr = self .diff .collapse_edges (sum_weights = True )
124- self .assertIsInstance (diff_attr , gn_multigraph .MultiGraphPlus )
124+ self .assertIsInstance (diff_attr , multigraph .MultiGraphPlus )
125125 # Looking at Charlie, contains 3 unique attributes
126126 cd = {'file02' : {0 : {'weight' : 7 ,
127127 'type' : ['commit' , 'issue' , 'review' ],
@@ -158,8 +158,8 @@ def test_diff_attr(self):
158158
159159
160160class NodeMergeTest (unittest .TestCase ):
161- """Tests for the node_merge() method within gn_multigraph .py"""
162- mg = gn_multigraph .MultiGraphPlus ()
161+ """Tests for the node_merge() method within multigraph .py"""
162+ mg = multigraph .MultiGraphPlus ()
163163 mg .add_node ('Alice' , attr_dict = {'id' : 'a01' ,
164164 'email' : 'alice@gmail.com' ,
165165 'phone' : '1(888)123-4567' ,
@@ -183,7 +183,7 @@ def test_basic_res(self):
183183 """Ensures the results of the method are appropriate"""
184184 mg_merged = self .mg_merged
185185 # Checking Return Value
186- self .assertIsInstance (mg_merged , gn_multigraph .MultiGraphPlus )
186+ self .assertIsInstance (mg_merged , multigraph .MultiGraphPlus )
187187 # Checking Nodes
188188 self .assertEqual (self .mg .number_of_nodes (), 4 ) # Checking before
189189 self .assertEqual (mg_merged .number_of_nodes (), 3 )
@@ -202,7 +202,7 @@ def test_basic_res(self):
202202 def test_list_attr (self ):
203203 """Are list attributes combined by node_merge?"""
204204 mg_merged = self .mg_merged
205- self .assertIsInstance (mg_merged , gn_multigraph .MultiGraphPlus )
205+ self .assertIsInstance (mg_merged , multigraph .MultiGraphPlus )
206206 self .assertEqual (len (mg_merged .node ['Alice Smith' ]['records' ]), 4 )
207207 self .assertSetEqual (set (mg_merged .node ['Alice Smith' ]['records' ]), {'hash1' , 'hash2' , 'hash3' , 'hash4' })
208208
0 commit comments