@@ -185,6 +185,25 @@ def sample_graph_names(request) -> str:
185
185
return request .param
186
186
187
187
188
+ @pytest .fixture (scope = "session" )
189
+ def get_test_graph_by_name () -> graph_fetcher :
190
+ """
191
+ Returns a known test graph requested if the graph location was included in test_graph_location.
192
+ """
193
+ test_graph_location : dict [str , str ] = {
194
+ "synthea" : "synthea_graph.json" ,
195
+ "world_development_indicators" : "world_development_indicators_graph.json" ,
196
+ }
197
+
198
+ @cache
199
+ def impl (name : str ) -> GraphMetadata :
200
+ file_name : str = test_graph_location [name ]
201
+ path : str = f"{ os .path .dirname (__file__ )} /test_metadata/{ file_name } "
202
+ return pydough .parse_json_metadata_from_file (file_path = path , graph_name = name )
203
+
204
+ return impl
205
+
206
+
188
207
@pytest .fixture (scope = "session" )
189
208
def get_mysql_defog_graphs () -> graph_fetcher :
190
209
"""
@@ -573,6 +592,41 @@ def sqlite_cryptbank_connection() -> DatabaseContext:
573
592
return DatabaseContext (DatabaseConnection (connection ), DatabaseDialect .SQLITE )
574
593
575
594
595
+ @pytest .fixture (scope = "session" )
596
+ def sqlite_custom_datasets_connection () -> DatabaseContext :
597
+ """
598
+ Returns the SQLITE database connection with all the custom datasets attached.
599
+ """
600
+ commands : list [str ] = [
601
+ "cd tests/gen_data" ,
602
+ "rm -fv synthea.db" ,
603
+ "rm -fv world_development_indicators.db" ,
604
+ "sqlite3 synthea.db < init_synthea.sql" ,
605
+ "sqlite3 world_development_indicators.db < init_world_indicators_sqlite.sql" ,
606
+ ]
607
+ # Get the shell commands required to re-create all the db files
608
+ shell_cmd : str = "; " .join (commands )
609
+
610
+ # Setup the directory to be the main PyDough directory.
611
+ base_dir : str = os .path .dirname (os .path .dirname (__file__ ))
612
+ # Setup the world development indicators database.
613
+ subprocess .run (shell_cmd , shell = True , check = True )
614
+ # Central in-memory connection
615
+ connection : sqlite3 .Connection = sqlite3 .connect (":memory:" )
616
+
617
+ # Dict: schema_name → database file path
618
+ dbs : dict [str , str ] = {
619
+ "synthea" : "tests/gen_data/synthea.db" ,
620
+ "wdi" : "tests/gen_data/world_development_indicators.db" ,
621
+ }
622
+
623
+ # Attach them all
624
+ for schema , path in dbs .items ():
625
+ path = os .path .join (base_dir , path )
626
+ connection .execute (f"ATTACH DATABASE '{ path } ' AS { schema } " )
627
+ return DatabaseContext (DatabaseConnection (connection ), DatabaseDialect .SQLITE )
628
+
629
+
576
630
SF_ENVS = ["SF_USERNAME" , "SF_PASSWORD" , "SF_ACCOUNT" ]
577
631
"""
578
632
Snowflake environment variables required for connection.
0 commit comments