Skip to content

Commit a04709c

Browse files
committed
test(sqlserver): add testsuite basic/ddl ALTER TABLE bridge tests and provider get_dialect
1 parent 4c35fd4 commit a04709c

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎tests/providers/basic.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@ def get_test_scenarios(self) -> List[str]:
341341
def get_yes_no_adapter(self) -> "BaseSQLTypeAdapter":
342342
return YesOrNoBooleanAdapter()
343343

344+
def get_dialect(self, scenario_name: str = "default"):
345+
"""Return a bare, fully-constructed SQL Server dialect instance.
346+
347+
Used by the ``feature/basic/ddl`` subtopic (expression/dialect
348+
contract). ``(16, 0, 0)`` advertises support for the ``IF
349+
[NOT] EXISTS`` ``DROP`` modifiers (available since 2016).
350+
"""
351+
from rhosocial.activerecord.backend.impl.sqlserver.dialect import SQLServerDialect
352+
353+
return SQLServerDialect(version=(16, 0, 0))
354+
344355
def _track_backend(self, backend_instance, collection: List) -> None:
345356
if backend_instance not in collection:
346357
collection.append(backend_instance)
@@ -544,6 +555,10 @@ def __init__(self):
544555
super().__init__()
545556
self._active_async_backends = []
546557

558+
async def get_dialect(self, scenario_name: str = "default"):
559+
"""Async mirror of ``BasicProviderBase.get_dialect``."""
560+
return super().get_dialect(scenario_name)
561+
547562
async def _setup_async_model(
548563
self, model_class: Type[ActiveRecord], scenario_name: str, table_name: str
549564
) -> Type[ActiveRecord]:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# tests/rhosocial/activerecord_sqlserver_test/feature/basic/ddl/conftest.py
2+
"""
3+
Pytest configuration for the basic/ddl ALTER TABLE tests.
4+
5+
This file imports fixtures from the corresponding testsuite subtopic, making
6+
them (and the ``requires_protocol`` protocol-check autouse fixture) available
7+
to the tests in this directory.
8+
"""
9+
10+
from rhosocial.activerecord.testsuite.feature.basic.ddl.conftest import * # noqa: F403
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# tests/rhosocial/activerecord_sqlserver_test/feature/basic/ddl/test_alter_table_if_exists.py
2+
"""
3+
ALTER TABLE IF [NOT] EXISTS tests (sync) for the SQL Server backend.
4+
5+
Thin bridge that runs the shared testsuite contract against the SQL Server
6+
dialect, which supports ``DROP COLUMN IF EXISTS`` / ``DROP CONSTRAINT
7+
IF EXISTS`` (2016+) but not ``ADD COLUMN IF NOT EXISTS``.
8+
"""
9+
10+
from rhosocial.activerecord.testsuite.feature.basic.ddl.test_alter_table_if_exists import * # noqa: F403
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# tests/rhosocial/activerecord_sqlserver_test/feature/basic/ddl/test_alter_table_if_exists_async.py
2+
"""
3+
ALTER TABLE IF [NOT] EXISTS tests (async) for the SQL Server backend.
4+
5+
Async mirror of ``test_alter_table_if_exists.py``.
6+
"""
7+
8+
from rhosocial.activerecord.testsuite.feature.basic.ddl.test_alter_table_if_exists_async import * # noqa: E501, F401, F403

0 commit comments

Comments
 (0)