cccs-eric commented on code in PR #7921: URL: https://github.com/apache/iceberg/pull/7921#discussion_r1261102802
########## python/tests/catalog/test_sql_integration.py: ########## @@ -0,0 +1,304 @@ +import os +from typing import Generator, List + +import pytest + +from pyiceberg.catalog import Catalog +from pyiceberg.catalog.sql import SQLCatalog, SQLCatalogBase +from pyiceberg.exceptions import ( + NamespaceAlreadyExistsError, + NamespaceNotEmptyError, + NoSuchNamespaceError, + NoSuchTableError, + TableAlreadyExistsError, +) +from pyiceberg.schema import Schema +from tests.conftest import clean_up, get_bucket_name, get_s3_path + +# The number of tables/databases used in list_table/namespace test +LIST_TEST_NUMBER = 2 + + [email protected](name="test_catalog", scope="module") +def fixture_test_catalog() -> Generator[SQLCatalog, None, None]: + """The pre- and post-setting of SQL integration test.""" + os.environ["AWS_TEST_BUCKET"] = "warehouse" + os.environ["AWS_REGION"] = "us-east-1" + os.environ["AWS_ACCESS_KEY_ID"] = "admin" + os.environ["AWS_SECRET_ACCESS_KEY"] = "password" + + props = { + "uri": "sqlite+pysqlite:///:memory:", + "warehouse": get_s3_path(get_bucket_name()), + "s3.endpoint": "http://localhost:9000", + "s3.access-key-id": "admin", + "s3.secret-access-key": "password", + } + test_catalog = SQLCatalog("test_sql_catalog", **props) + SQLCatalogBase.metadata.create_all(test_catalog.engine) Review Comment: yes, I create an `initialize_tables()` function in the catalog, very handy. ########## python/tests/catalog/test_sql_integration.py: ########## @@ -0,0 +1,304 @@ +import os +from typing import Generator, List + +import pytest + +from pyiceberg.catalog import Catalog +from pyiceberg.catalog.sql import SQLCatalog, SQLCatalogBase +from pyiceberg.exceptions import ( + NamespaceAlreadyExistsError, + NamespaceNotEmptyError, + NoSuchNamespaceError, + NoSuchTableError, + TableAlreadyExistsError, +) +from pyiceberg.schema import Schema +from tests.conftest import clean_up, get_bucket_name, get_s3_path + +# The number of tables/databases used in list_table/namespace test +LIST_TEST_NUMBER = 2 + + [email protected](name="test_catalog", scope="module") +def fixture_test_catalog() -> Generator[SQLCatalog, None, None]: + """The pre- and post-setting of SQL integration test.""" + os.environ["AWS_TEST_BUCKET"] = "warehouse" + os.environ["AWS_REGION"] = "us-east-1" + os.environ["AWS_ACCESS_KEY_ID"] = "admin" + os.environ["AWS_SECRET_ACCESS_KEY"] = "password" + + props = { + "uri": "sqlite+pysqlite:///:memory:", + "warehouse": get_s3_path(get_bucket_name()), + "s3.endpoint": "http://localhost:9000", + "s3.access-key-id": "admin", + "s3.secret-access-key": "password", + } + test_catalog = SQLCatalog("test_sql_catalog", **props) + SQLCatalogBase.metadata.create_all(test_catalog.engine) Review Comment: yes, I created an `initialize_tables()` function in the catalog, very handy. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
