File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ def get_graph(
165165 """
166166 self ._check_input (software , graph_type )
167167
168- if index and date :
168+ if index is not None and date is not None :
169169 raise ValueError (
170170 "You must provide either the date or the index of the graph, not both."
171171 )
@@ -177,6 +177,8 @@ def get_graph(
177177 # Fetch latest graph
178178 date = self ._fetch_latest_date (software , graph_type )
179179
180+ assert date is not None
181+
180182 interactions_csv_file = f"{ software } /{ graph_type } /{ date } /interactions.csv"
181183 interaction_records = self .dataset .records (interactions_csv_file )
182184
Original file line number Diff line number Diff line change @@ -89,6 +89,21 @@ def test_get_graph():
8989 graph2 = loader .get_graph (software , graph_type , index = - 1 )
9090 assert graph1 .number_of_edges () == graph2 .number_of_edges ()
9191
92+ ########### FURTHER TESTS ###############
93+ available_dates = loader .list_available_dates (software , graph_type )
94+ date = available_dates [0 ]
95+ graph3 = loader .get_graph (software , graph_type , date = date )
96+
97+ if not graph_type == "federation" : # Because Federation is undirected
98+ csv_file = f"{ software } /{ graph_type } /{ date } /interactions.csv"
99+ records = loader .dataset .records (csv_file )
100+
101+ assert graph3 .number_of_edges () == len (list (records ))
102+
103+ # Test index selection
104+ graph4 = loader .get_graph (software , graph_type , index = 0 )
105+ assert graph3 .number_of_edges () == graph4 .number_of_edges ()
106+
92107 # Check graph consistency
93108 peertube_graph = loader .get_graph ("peertube" , "follow" , date = "20250324" )
94109 assert peertube_graph .number_of_edges () == 19171
You can’t perform that action at this time.
0 commit comments