Skip to content

Commit

Permalink
postgres text fix
Browse files Browse the repository at this point in the history
  • Loading branch information
skarakuzu committed Feb 11, 2025
1 parent cc65504 commit 5821407
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions tiled/_tests/adapters/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,31 @@


@pytest.fixture
def data_source_from_init_storage(tmp_path: Path) -> DataSource[TableStructure]:
table = pa.Table.from_arrays(data0, names)
structure = TableStructure.from_arrow_table(table, npartitions=1)
data_source = DataSource(
management=Management.writable,
mimetype="application/x-tiled-sql-table",
structure_family=StructureFamily.table,
structure=structure,
assets=[],
)
data_uri = f"sqlite:///{tmp_path}/test.db"
storage = Storage(filesystem=None, sql=data_uri)
return SQLAdapter.init_storage(
data_source=data_source, storage=storage, path_parts=[]
)

def data_source_from_init_storage() -> DataSource[TableStructure]:
def _data_source_from_init_storage(data_uri):
table = pa.Table.from_arrays(data0, names)
structure = TableStructure.from_arrow_table(table, npartitions=1)
data_source = DataSource(
management=Management.writable,
mimetype="application/x-tiled-sql-table",
structure_family=StructureFamily.table,
structure=structure,
assets=[],
)

storage = Storage(filesystem=None, sql=data_uri)
return SQLAdapter.init_storage(
data_source=data_source, storage=storage, path_parts=[]
)
return _data_source_from_init_storage

@pytest.fixture
def adapter_sql(
tmp_path: Path,
data_source_from_init_storage: DataSource[TableStructure],
) -> Generator[SQLAdapter, None, None]:
data_source = data_source_from_init_storage
data_uri = f"sqlite:///{tmp_path}/test.db"
data_source = data_source_from_init_storage(data_uri)
yield SQLAdapter(
data_source.assets[0].data_uri,
data_source.structure,
Expand Down Expand Up @@ -113,7 +116,7 @@ def postgres_uri() -> str:
def adapter_psql(
data_source_from_init_storage: DataSource[TableStructure], postgres_uri: str
) -> SQLAdapter:
data_source = data_source_from_init_storage
data_source = data_source_from_init_storage(postgres_uri)
return SQLAdapter(
postgres_uri,
data_source.structure,
Expand Down

0 comments on commit 5821407

Please sign in to comment.