|
| 1 | +from unittest.mock import Mock |
| 2 | + |
| 3 | +from splitgraph.ingestion.snowflake import SnowflakeDataSource |
| 4 | + |
| 5 | + |
| 6 | +def test_snowflake_data_source_dburl_conversion(): |
| 7 | + source = SnowflakeDataSource( |
| 8 | + Mock(), |
| 9 | + credentials={ |
| 10 | + "username": "username", |
| 11 | + "password": "password", |
| 12 | + "account": "abcdef.eu-west-1.aws", |
| 13 | + }, |
| 14 | + params={ |
| 15 | + "database": "SOME_DB", |
| 16 | + "schema": "TPCH_SF100", |
| 17 | + "warehouse": "my_warehouse", |
| 18 | + "role": "role", |
| 19 | + }, |
| 20 | + ) |
| 21 | + |
| 22 | + assert source.get_server_options() == { |
| 23 | + "db_url": "snowflake://username:[email protected]/SOME_DB/TPCH_SF100warehouse=my_warehouse&role=role", |
| 24 | + "wrapper": "multicorn.sqlalchemyfdw.SqlAlchemyFdw", |
| 25 | + } |
| 26 | + |
| 27 | + source = SnowflakeDataSource( |
| 28 | + Mock(), |
| 29 | + credentials={ |
| 30 | + "username": "username", |
| 31 | + "password": "password", |
| 32 | + "account": "abcdef.eu-west-1.aws", |
| 33 | + }, |
| 34 | + params={ |
| 35 | + "database": "SOME_DB", |
| 36 | + "tables": { |
| 37 | + "test_table": { |
| 38 | + "schema": {"col_1": "int", "col_2": "varchar"}, |
| 39 | + "options": {"subquery": "SELECT col_1, col_2 FROM other_table"}, |
| 40 | + } |
| 41 | + }, |
| 42 | + }, |
| 43 | + ) |
| 44 | + |
| 45 | + assert source.get_table_options("test_table") == { |
| 46 | + "subquery": "SELECT col_1, col_2 FROM other_table", |
| 47 | + "tablename": "test_table", |
| 48 | + } |
0 commit comments