File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ release = [
112112 " twine<6" ,
113113]
114114test = [
115+ " cratedb-toolkit[testing]" ,
115116 " dask[dataframe]" ,
116117 " pandas<2.3" ,
117118 " pueblo>=0.0.7" ,
Original file line number Diff line number Diff line change 1+ # Copyright (c) 2021-2023, Crate.io Inc.
2+ # Distributed under the terms of the AGPLv3 license, see LICENSE.
3+ import pytest
4+ from cratedb_toolkit .testing .testcontainers .cratedb import CrateDBTestAdapter
5+
6+ # Use different schemas for storing the subsystem database tables, and the
7+ # test/example data, so that they do not accidentally touch the default `doc`
8+ # schema.
9+ TESTDRIVE_EXT_SCHEMA = "testdrive-ext"
10+ TESTDRIVE_DATA_SCHEMA = "testdrive-data"
11+
12+
13+ @pytest .fixture (scope = "session" )
14+ def cratedb_service ():
15+ """
16+ Provide a CrateDB service instance to the test suite.
17+ """
18+ db = CrateDBTestAdapter ()
19+ db .start ()
20+ yield db
21+ db .stop ()
Original file line number Diff line number Diff line change 1+ import sqlalchemy as sa
2+
3+ from tests .conftest import TESTDRIVE_DATA_SCHEMA
4+
5+
6+ def test_correct_schema (cratedb_service ):
7+ """
8+ Tests that the correct schema is being picked up.
9+ """
10+ database = cratedb_service .database
11+
12+ tablename = f'"{ TESTDRIVE_DATA_SCHEMA } "."foobar"'
13+ inspector : sa .Inspector = sa .inspect (database .engine )
14+ database .run_sql (f"CREATE TABLE { tablename } AS SELECT 1" )
15+
16+ assert TESTDRIVE_DATA_SCHEMA in inspector .get_schema_names ()
17+
18+ table_names = inspector .get_table_names (schema = TESTDRIVE_DATA_SCHEMA )
19+ assert table_names == ["foobar" ]
20+
21+ view_names = inspector .get_view_names (schema = TESTDRIVE_DATA_SCHEMA )
22+ assert view_names == []
23+
24+ indexes = inspector .get_indexes (tablename )
25+ assert indexes == []
You can’t perform that action at this time.
0 commit comments