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
30 changes: 0 additions & 30 deletions docs/examples/patterns/mock_testing.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/usage/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Choose a topic
:link: testing
:link-type: doc

Unit test with mock adapters and integration test patterns.
Unit and integration test patterns.

.. grid-item-card:: ETL & Data Pipelines
:link: etl
Expand Down
50 changes: 14 additions & 36 deletions docs/usage/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,6 @@ Testing

SQLSpec provides tools for both unit and integration testing of database code.

Mock Adapter for Unit Tests
---------------------------

``MockSyncConfig`` and ``MockAsyncConfig`` use an in-memory SQLite backend with
optional dialect transpilation. Write SQL in your production dialect (PostgreSQL,
MySQL, Oracle) and it gets transpiled to SQLite before execution.

.. literalinclude:: /examples/patterns/mock_testing.py
:language: python
:caption: ``mock adapter for unit tests``
:start-after: # start-example
:end-before: # end-example
:dedent: 4
:no-upgrade:

Key features:

- ``target_dialect`` accepts ``"postgres"``, ``"mysql"``, ``"oracle"``, or ``"sqlite"``
- SQL is automatically transpiled to SQLite for execution
- No external database required -- runs entirely in-memory
- Supports ``initial_sql`` parameter for schema setup on connection create

Integration Test Patterns
-------------------------

For integration tests against real databases, use the standard ``SQLSpec`` +
adapter config pattern with temporary databases.

.. literalinclude:: /examples/patterns/integration_testing.py
:language: python
:caption: ``integration test fixtures``
:start-after: # start-example
:end-before: # end-example
:dedent: 4
:no-upgrade:

Pytest Fixture Tips
-------------------

Expand All @@ -64,6 +28,20 @@ Pytest Fixture Tips
session.execute("create table users (id integer primary key, name text)")
yield session

Integration Test Patterns
-------------------------

For integration tests against real databases, use the standard ``SQLSpec`` +
adapter config pattern with temporary databases.

.. literalinclude:: /examples/patterns/integration_testing.py
:language: python
:caption: ``integration test fixtures``
:start-after: # start-example
:end-before: # end-example
:dedent: 4
:no-upgrade:

Related Guides
--------------

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ exclude = [
"sqlspec/dialects/**/*.py", # Keep SQLGlot dialect subclasses interpreted
"sqlspec/**/__init__.py", # Init files (usually just imports)
"sqlspec/protocols.py", # Protocol definitions
"sqlspec/adapters/mock/**", # Mock adapter (testing only)
"sqlspec/migrations/commands.py", # Migration command CLI (dynamic imports)
"sqlspec/data_dictionary/_loader.py", # Loader relies on __file__ which fails in compiled modules
"sqlspec/extensions/fastapi/providers.py", # Uses SingletonMeta metaclass
Expand Down
79 changes: 0 additions & 79 deletions sqlspec/adapters/mock/__init__.py

This file was deleted.

Loading
Loading