Skip to content

Commit d7dbfbb

Browse files
authored
feat: remove mock driver (#422)
The mock driver missed the mark a bit. It's much more difficult to simulate other DB drivers that I anticipated with this implementation. Removing until there's a more refined plan.
1 parent b1ca497 commit d7dbfbb

29 files changed

Lines changed: 578 additions & 6366 deletions

docs/examples/patterns/mock_testing.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/usage/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Choose a topic
7676
:link: testing
7777
:link-type: doc
7878

79-
Unit test with mock adapters and integration test patterns.
79+
Unit and integration test patterns.
8080

8181
.. grid-item-card:: ETL & Data Pipelines
8282
:link: etl

docs/usage/testing.rst

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,6 @@ Testing
33

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

6-
Mock Adapter for Unit Tests
7-
---------------------------
8-
9-
``MockSyncConfig`` and ``MockAsyncConfig`` use an in-memory SQLite backend with
10-
optional dialect transpilation. Write SQL in your production dialect (PostgreSQL,
11-
MySQL, Oracle) and it gets transpiled to SQLite before execution.
12-
13-
.. literalinclude:: /examples/patterns/mock_testing.py
14-
:language: python
15-
:caption: ``mock adapter for unit tests``
16-
:start-after: # start-example
17-
:end-before: # end-example
18-
:dedent: 4
19-
:no-upgrade:
20-
21-
Key features:
22-
23-
- ``target_dialect`` accepts ``"postgres"``, ``"mysql"``, ``"oracle"``, or ``"sqlite"``
24-
- SQL is automatically transpiled to SQLite for execution
25-
- No external database required -- runs entirely in-memory
26-
- Supports ``initial_sql`` parameter for schema setup on connection create
27-
28-
Integration Test Patterns
29-
-------------------------
30-
31-
For integration tests against real databases, use the standard ``SQLSpec`` +
32-
adapter config pattern with temporary databases.
33-
34-
.. literalinclude:: /examples/patterns/integration_testing.py
35-
:language: python
36-
:caption: ``integration test fixtures``
37-
:start-after: # start-example
38-
:end-before: # end-example
39-
:dedent: 4
40-
:no-upgrade:
41-
426
Pytest Fixture Tips
437
-------------------
448

@@ -64,6 +28,20 @@ Pytest Fixture Tips
6428
session.execute("create table users (id integer primary key, name text)")
6529
yield session
6630
31+
Integration Test Patterns
32+
-------------------------
33+
34+
For integration tests against real databases, use the standard ``SQLSpec`` +
35+
adapter config pattern with temporary databases.
36+
37+
.. literalinclude:: /examples/patterns/integration_testing.py
38+
:language: python
39+
:caption: ``integration test fixtures``
40+
:start-after: # start-example
41+
:end-before: # end-example
42+
:dedent: 4
43+
:no-upgrade:
44+
6745
Related Guides
6846
--------------
6947

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ exclude = [
183183
"sqlspec/dialects/**/*.py", # Keep SQLGlot dialect subclasses interpreted
184184
"sqlspec/**/__init__.py", # Init files (usually just imports)
185185
"sqlspec/protocols.py", # Protocol definitions
186-
"sqlspec/adapters/mock/**", # Mock adapter (testing only)
187186
"sqlspec/migrations/commands.py", # Migration command CLI (dynamic imports)
188187
"sqlspec/data_dictionary/_loader.py", # Loader relies on __file__ which fails in compiled modules
189188
"sqlspec/extensions/fastapi/providers.py", # Uses SingletonMeta metaclass

sqlspec/adapters/mock/__init__.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)