Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pysql-test CI
name: pgsql-test CI

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/pysql_test/__init__.py → src/pgsql_test/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/pysql_test/admin.py → src/pgsql_test/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
2 changes: 1 addition & 1 deletion src/pysql_test/client.py → src/pgsql_test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
16 changes: 8 additions & 8 deletions src/pysql_test/connect.py → src/pgsql_test/connect.py
Original file line number Diff line number Diff line change
@@ -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.
"""
Expand All @@ -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__)

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/pysql_test/manager.py → src/pgsql_test/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -206,14 +206,14 @@ 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.

Args:
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]}"
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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__)

Expand Down
4 changes: 2 additions & 2 deletions src/pysql_test/seed/pgpm.py → src/pgsql_test/seed/pgpm.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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__)

Expand Down
2 changes: 1 addition & 1 deletion src/pysql_test/seed/sql.py → src/pgsql_test/seed/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
2 changes: 1 addition & 1 deletion src/pysql_test/types.py → src/pgsql_test/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Type definitions for pysql-test."""
"""Type definitions for pgsql-test."""

from dataclasses import dataclass
from typing import Any, Protocol, TypedDict
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Tests for pysql-test."""
"""Tests for pgsql-test."""
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
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
from pathlib import Path

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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
%project=test-module
%uri=test-module

schemas/test_app 2026-01-22T00:00:00Z pysql-test <test@pysql-test.dev> # add test_app schema
schemas/test_app 2026-01-22T00:00:00Z pgsql-test <test@pgsql-test.dev> # add test_app schema
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
18 changes: 9 additions & 9 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Basic tests for pysql-test framework.
Basic tests for pgsql-test framework.

These tests verify the core functionality of the testing framework itself.
"""


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:
Expand All @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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_")
4 changes: 2 additions & 2 deletions tests/test_example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
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.
"""

import pytest

from pysql_test import get_connections, seed
from pgsql_test import get_connections, seed


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pets_rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pytest

from pysql_test import get_connections, seed
from pgsql_test import get_connections, seed


@pytest.fixture
Expand Down
6 changes: 3 additions & 3 deletions tests/test_pgpm_integration.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down