From 88fc8638cad2d5480dd5f4497bc9a3c1a57041f4 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Thu, 22 Jan 2026 04:27:29 +0000 Subject: [PATCH] Rename pysql_test to pgsql_test to match project name - Renamed src/pysql_test/ directory to src/pgsql_test/ - Updated all Python imports from pysql_test to pgsql_test - Updated pyproject.toml package name and ruff config - Updated workflow name from pysql-test CI to pgsql-test CI - Updated test assertions to use pgsql_test_ prefix - Updated documentation and comments throughout - Updated test fixtures (package.json, pgpm.plan, etc.) The package name 'pgsql-test' in pyproject.toml was already correct, but the importable module name was inconsistent (pysql_test vs pgsql_test). This change aligns the module name with the package and repository name. --- .github/workflows/test.yml | 2 +- pyproject.toml | 4 ++-- src/{pysql_test => pgsql_test}/__init__.py | 12 ++++++------ src/{pysql_test => pgsql_test}/admin.py | 2 +- src/{pysql_test => pgsql_test}/client.py | 2 +- src/{pysql_test => pgsql_test}/connect.py | 16 ++++++++-------- src/{pysql_test => pgsql_test}/manager.py | 10 +++++----- .../seed/__init__.py | 8 ++++---- .../seed/adapters.py | 4 ++-- src/{pysql_test => pgsql_test}/seed/pgpm.py | 4 ++-- src/{pysql_test => pgsql_test}/seed/sql.py | 2 +- src/{pysql_test => pgsql_test}/types.py | 2 +- tests/__init__.py | 2 +- tests/conftest.py | 8 ++++---- .../packages/test-module/package.json | 4 ++-- .../packages/test-module/pgpm.plan | 2 +- .../packages/test-module/test-module.control | 2 +- tests/sql/schema.sql | 2 +- tests/test_basic.py | 18 +++++++++--------- tests/test_example.py | 4 ++-- tests/test_pets_rollback.py | 2 +- tests/test_pgpm_integration.py | 6 +++--- 22 files changed, 59 insertions(+), 59 deletions(-) rename src/{pysql_test => pgsql_test}/__init__.py (51%) rename src/{pysql_test => pgsql_test}/admin.py (99%) rename src/{pysql_test => pgsql_test}/client.py (99%) rename src/{pysql_test => pgsql_test}/connect.py (93%) rename src/{pysql_test => pgsql_test}/manager.py (96%) rename src/{pysql_test => pgsql_test}/seed/__init__.py (64%) rename src/{pysql_test => pgsql_test}/seed/adapters.py (97%) rename src/{pysql_test => pgsql_test}/seed/pgpm.py (98%) rename src/{pysql_test => pgsql_test}/seed/sql.py (97%) rename src/{pysql_test => pgsql_test}/types.py (97%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a00415..4b65497 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: pysql-test CI +name: pgsql-test CI on: push: diff --git a/pyproject.toml b/pyproject.toml index 021c0a6..82f3662 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ "Topic :: Database", "Topic :: Software Development :: Testing", ] -packages = [{include = "pysql_test", from = "src"}] +packages = [{include = "pgsql_test", from = "src"}] [tool.poetry.dependencies] python = "^3.10" @@ -58,7 +58,7 @@ ignore = [ ] [tool.ruff.lint.isort] -known-first-party = ["pysql_test"] +known-first-party = ["pgsql_test"] [tool.mypy] python_version = "3.10" diff --git a/src/pysql_test/__init__.py b/src/pgsql_test/__init__.py similarity index 51% rename from src/pysql_test/__init__.py rename to src/pgsql_test/__init__.py index 52641cd..03e7a60 100644 --- a/src/pysql_test/__init__.py +++ b/src/pgsql_test/__init__.py @@ -1,15 +1,15 @@ """ -pysql-test: PostgreSQL testing framework for Python. +pgsql-test: PostgreSQL testing framework for Python. Instant, isolated PostgreSQL databases for each test with automatic transaction rollback, context switching, and clean seeding. """ -from pysql_test import seed -from pysql_test.admin import DbAdmin -from pysql_test.client import PgTestClient -from pysql_test.connect import get_connections -from pysql_test.manager import PgTestConnector +from pgsql_test import seed +from pgsql_test.admin import DbAdmin +from pgsql_test.client import PgTestClient +from pgsql_test.connect import get_connections +from pgsql_test.manager import PgTestConnector __all__ = [ "get_connections", diff --git a/src/pysql_test/admin.py b/src/pgsql_test/admin.py similarity index 99% rename from src/pysql_test/admin.py rename to src/pgsql_test/admin.py index 78118c2..cc3dde6 100644 --- a/src/pysql_test/admin.py +++ b/src/pgsql_test/admin.py @@ -13,7 +13,7 @@ from psycopg2 import sql from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT -from pysql_test.types import PgConfig +from pgsql_test.types import PgConfig logger = logging.getLogger(__name__) diff --git a/src/pysql_test/client.py b/src/pgsql_test/client.py similarity index 99% rename from src/pysql_test/client.py rename to src/pgsql_test/client.py index 400d292..326ac73 100644 --- a/src/pysql_test/client.py +++ b/src/pgsql_test/client.py @@ -13,7 +13,7 @@ import psycopg2 from psycopg2.extras import RealDictCursor -from pysql_test.types import PgConfig, QueryResult +from pgsql_test.types import PgConfig, QueryResult logger = logging.getLogger(__name__) diff --git a/src/pysql_test/connect.py b/src/pgsql_test/connect.py similarity index 93% rename from src/pysql_test/connect.py rename to src/pgsql_test/connect.py index 184c49b..ea952a1 100644 --- a/src/pysql_test/connect.py +++ b/src/pgsql_test/connect.py @@ -1,5 +1,5 @@ """ -Connection management for pysql-test. +Connection management for pgsql-test. Provides the main entry point for setting up test database connections. """ @@ -12,10 +12,10 @@ from dataclasses import dataclass from typing import Any -from pysql_test.admin import DbAdmin -from pysql_test.client import PgTestClient -from pysql_test.manager import PgTestConnector, generate_test_db_name -from pysql_test.types import ConnectionOptions, PgConfig, SeedContext +from pgsql_test.admin import DbAdmin +from pgsql_test.client import PgTestClient +from pgsql_test.manager import PgTestConnector, generate_test_db_name +from pgsql_test.types import ConnectionOptions, PgConfig, SeedContext logger = logging.getLogger(__name__) @@ -83,7 +83,7 @@ def get_connections( """ Set up a fresh PostgreSQL test database and return connection objects. - This is the main entry point for pysql-test. It: + This is the main entry point for pgsql-test. It: 1. Creates a new isolated database with a UUID name 2. Installs any requested extensions 3. Runs seed adapters to populate the database @@ -98,7 +98,7 @@ def get_connections( ConnectionResult with pg, db, admin, manager, and teardown function. Example: - from pysql_test import get_connections, seed + from pgsql_test import get_connections, seed # Basic usage conn = get_connections() @@ -122,7 +122,7 @@ def db(): options = connection_options or {} # Generate unique database name - prefix = options.get("prefix", "pysql_test_") + prefix = options.get("prefix", "pgsql_test_") test_db_name = generate_test_db_name(prefix) # Create admin connection to root database diff --git a/src/pysql_test/manager.py b/src/pgsql_test/manager.py similarity index 96% rename from src/pysql_test/manager.py rename to src/pgsql_test/manager.py index f4b02bc..a22f233 100644 --- a/src/pysql_test/manager.py +++ b/src/pgsql_test/manager.py @@ -13,9 +13,9 @@ import uuid from typing import Any -from pysql_test.admin import DbAdmin -from pysql_test.client import PgTestClient -from pysql_test.types import PgConfig +from pgsql_test.admin import DbAdmin +from pgsql_test.client import PgTestClient +from pgsql_test.types import PgConfig logger = logging.getLogger(__name__) @@ -206,7 +206,7 @@ def kill(self, client: PgTestClient) -> None: self.drop(client.config) -def generate_test_db_name(prefix: str = "pysql_test_") -> str: +def generate_test_db_name(prefix: str = "pgsql_test_") -> str: """ Generate a unique test database name. @@ -214,6 +214,6 @@ def generate_test_db_name(prefix: str = "pysql_test_") -> str: prefix: Prefix for the database name Returns: - A unique database name like "pysql_test_abc123..." + A unique database name like "pgsql_test_abc123..." """ return f"{prefix}{uuid.uuid4().hex[:12]}" diff --git a/src/pysql_test/seed/__init__.py b/src/pgsql_test/seed/__init__.py similarity index 64% rename from src/pysql_test/seed/__init__.py rename to src/pgsql_test/seed/__init__.py index 97b70f4..0d5ccb0 100644 --- a/src/pysql_test/seed/__init__.py +++ b/src/pgsql_test/seed/__init__.py @@ -1,5 +1,5 @@ """ -Seed adapters for pysql-test. +Seed adapters for pgsql-test. Provides composable seeding strategies for test databases: - sqlfile: Execute raw SQL files @@ -8,9 +8,9 @@ - pgpm: Run pgpm migrations (requires pgpm CLI) """ -from pysql_test.seed.adapters import compose, fn -from pysql_test.seed.pgpm import pgpm -from pysql_test.seed.sql import sqlfile +from pgsql_test.seed.adapters import compose, fn +from pgsql_test.seed.pgpm import pgpm +from pgsql_test.seed.sql import sqlfile __all__ = [ "sqlfile", diff --git a/src/pysql_test/seed/adapters.py b/src/pgsql_test/seed/adapters.py similarity index 97% rename from src/pysql_test/seed/adapters.py rename to src/pgsql_test/seed/adapters.py index bf7e5c5..a286a09 100644 --- a/src/pysql_test/seed/adapters.py +++ b/src/pgsql_test/seed/adapters.py @@ -1,5 +1,5 @@ """ -Generic seed adapters for pysql-test. +Generic seed adapters for pgsql-test. Provides composable seeding utilities: - fn: Run custom Python functions @@ -13,7 +13,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from pysql_test.types import SeedContext + from pgsql_test.types import SeedContext logger = logging.getLogger(__name__) diff --git a/src/pysql_test/seed/pgpm.py b/src/pgsql_test/seed/pgpm.py similarity index 98% rename from src/pysql_test/seed/pgpm.py rename to src/pgsql_test/seed/pgpm.py index 47b85a3..b66bbef 100644 --- a/src/pysql_test/seed/pgpm.py +++ b/src/pgsql_test/seed/pgpm.py @@ -1,5 +1,5 @@ """ -pgpm seed adapter for pysql-test. +pgpm seed adapter for pgsql-test. Provides integration with pgpm (PostgreSQL Package Manager) for running database migrations as part of test seeding. @@ -15,7 +15,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from pysql_test.types import SeedContext + from pgsql_test.types import SeedContext logger = logging.getLogger(__name__) diff --git a/src/pysql_test/seed/sql.py b/src/pgsql_test/seed/sql.py similarity index 97% rename from src/pysql_test/seed/sql.py rename to src/pgsql_test/seed/sql.py index 84b13c6..0f09c08 100644 --- a/src/pysql_test/seed/sql.py +++ b/src/pgsql_test/seed/sql.py @@ -11,7 +11,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from pysql_test.types import SeedContext + from pgsql_test.types import SeedContext logger = logging.getLogger(__name__) diff --git a/src/pysql_test/types.py b/src/pgsql_test/types.py similarity index 97% rename from src/pysql_test/types.py rename to src/pgsql_test/types.py index 2d8e571..7f3a0e3 100644 --- a/src/pysql_test/types.py +++ b/src/pgsql_test/types.py @@ -1,4 +1,4 @@ -"""Type definitions for pysql-test.""" +"""Type definitions for pgsql-test.""" from dataclasses import dataclass from typing import Any, Protocol, TypedDict diff --git a/tests/__init__.py b/tests/__init__.py index 6c8e4e9..23e7db5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""Tests for pysql-test.""" +"""Tests for pgsql-test.""" diff --git a/tests/conftest.py b/tests/conftest.py index 86f6a26..78364d0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ """ -Pytest configuration and fixtures for pysql-test. +Pytest configuration and fixtures for pgsql-test. -This module provides reusable fixtures for testing the pysql-test framework itself. +This module provides reusable fixtures for testing the pgsql-test framework itself. """ import os @@ -9,8 +9,8 @@ import pytest -from pysql_test import get_connections -from pysql_test.types import PgConfig +from pgsql_test import get_connections +from pgsql_test.types import PgConfig def get_test_pg_config() -> PgConfig: diff --git a/tests/fixtures/pgpm-workspace/packages/test-module/package.json b/tests/fixtures/pgpm-workspace/packages/test-module/package.json index f9a2012..faa839f 100644 --- a/tests/fixtures/pgpm-workspace/packages/test-module/package.json +++ b/tests/fixtures/pgpm-workspace/packages/test-module/package.json @@ -1,7 +1,7 @@ { "name": "test-module", "version": "0.0.1", - "description": "Test module for pysql-test pgpm integration", - "author": "pysql-test", + "description": "Test module for pgsql-test pgpm integration", + "author": "pgsql-test", "license": "MIT" } diff --git a/tests/fixtures/pgpm-workspace/packages/test-module/pgpm.plan b/tests/fixtures/pgpm-workspace/packages/test-module/pgpm.plan index a1bc5fe..258d08e 100644 --- a/tests/fixtures/pgpm-workspace/packages/test-module/pgpm.plan +++ b/tests/fixtures/pgpm-workspace/packages/test-module/pgpm.plan @@ -2,4 +2,4 @@ %project=test-module %uri=test-module -schemas/test_app 2026-01-22T00:00:00Z pysql-test # add test_app schema +schemas/test_app 2026-01-22T00:00:00Z pgsql-test # add test_app schema diff --git a/tests/fixtures/pgpm-workspace/packages/test-module/test-module.control b/tests/fixtures/pgpm-workspace/packages/test-module/test-module.control index 6abbbd9..233a459 100644 --- a/tests/fixtures/pgpm-workspace/packages/test-module/test-module.control +++ b/tests/fixtures/pgpm-workspace/packages/test-module/test-module.control @@ -1,5 +1,5 @@ # test-module extension -comment = 'test-module extension for pysql-test' +comment = 'test-module extension for pgsql-test' default_version = '0.0.1' module_pathname = '$libdir/test-module' requires = 'plpgsql' diff --git a/tests/sql/schema.sql b/tests/sql/schema.sql index bc84421..ad14f3a 100644 --- a/tests/sql/schema.sql +++ b/tests/sql/schema.sql @@ -1,4 +1,4 @@ --- Test schema for pysql-test +-- Test schema for pgsql-test -- This file is used to test the SQL file seeding functionality CREATE TABLE IF NOT EXISTS users ( diff --git a/tests/test_basic.py b/tests/test_basic.py index 0751bcb..39db38c 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,5 +1,5 @@ """ -Basic tests for pysql-test framework. +Basic tests for pgsql-test framework. These tests verify the core functionality of the testing framework itself. """ @@ -7,9 +7,9 @@ import pytest -from pysql_test import get_connections, seed -from pysql_test.admin import DbAdmin -from pysql_test.manager import generate_test_db_name +from pgsql_test import get_connections, seed +from pgsql_test.admin import DbAdmin +from pgsql_test.manager import generate_test_db_name class TestGetConnections: @@ -27,8 +27,8 @@ def test_creates_isolated_database(self, pg_config): # Verify the database name is unique (contains UUID) db_name = conn.pg.config.get("database", "") - assert db_name.startswith("pysql_test_") - assert len(db_name) > len("pysql_test_") + assert db_name.startswith("pgsql_test_") + assert len(db_name) > len("pgsql_test_") finally: conn.teardown() @@ -264,7 +264,7 @@ class TestDbAdmin: def test_create_and_drop_database(self, pg_config): """Test creating and dropping a database.""" admin = DbAdmin(pg_config) - test_db = f"pysql_admin_test_{generate_test_db_name('')}" + test_db = f"pgsql_admin_test_{generate_test_db_name('')}" try: # Create @@ -290,7 +290,7 @@ def test_install_extensions(self, pg_config): admin.install_extensions(["uuid-ossp"], test_db) # Verify extension is installed by connecting to the DB - from pysql_test.client import PgTestClient + from pgsql_test.client import PgTestClient client_config = {**pg_config, "database": test_db} client = PgTestClient(client_config) client.connect() @@ -322,4 +322,4 @@ def test_uses_prefix(self): def test_default_prefix(self): """Test the default prefix.""" name = generate_test_db_name() - assert name.startswith("pysql_test_") + assert name.startswith("pgsql_test_") diff --git a/tests/test_example.py b/tests/test_example.py index c639bd2..ba896ae 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -1,5 +1,5 @@ """ -Simple example test demonstrating pysql-test usage. +Simple example test demonstrating pgsql-test usage. This is a minimal example showing how to use the testing framework for PostgreSQL integration tests with automatic database isolation. @@ -7,7 +7,7 @@ import pytest -from pysql_test import get_connections, seed +from pgsql_test import get_connections, seed @pytest.fixture diff --git a/tests/test_pets_rollback.py b/tests/test_pets_rollback.py index a2f1d06..51a1e18 100644 --- a/tests/test_pets_rollback.py +++ b/tests/test_pets_rollback.py @@ -10,7 +10,7 @@ import pytest -from pysql_test import get_connections, seed +from pgsql_test import get_connections, seed @pytest.fixture diff --git a/tests/test_pgpm_integration.py b/tests/test_pgpm_integration.py index b095d01..47c31b7 100644 --- a/tests/test_pgpm_integration.py +++ b/tests/test_pgpm_integration.py @@ -1,5 +1,5 @@ """ -pgpm integration tests for pysql-test. +pgpm integration tests for pgsql-test. These tests demonstrate using seed.pgpm() to run pgpm migrations as part of test database seeding. @@ -13,7 +13,7 @@ import pytest -from pysql_test import get_connections, seed +from pgsql_test import get_connections, seed # Path to the pre-scaffolded pgpm workspace fixture FIXTURE_PATH = Path(__file__).parent / "fixtures" / "pgpm-workspace" / "packages" / "test-module" @@ -75,7 +75,7 @@ def test_pgpm_faker_city_function(pgpm_db): Test that faker.city() function works. This demonstrates the full pgpm integration flow: - 1. pysql-test creates isolated database + 1. pgsql-test creates isolated database 2. seed.pgpm() runs pgpm deploy 3. pgpm deploys test-module + @pgpm/faker dependency 4. Test can use faker functions