Skip to content

Commit 77e3f00

Browse files
committed
chore(sqlserver): support TESTSUITE_ACTIVE_SCENARIOS filtering and raise core dependency
- Scenario filtering reads generic TESTSUITE_ACTIVE_SCENARIOS env var (fallback from backend-local SQLSERVER_ACTIVE_SCENARIOS) so --scenarios works when running tests from either the testsuite dir or this repo - Raise rhosocial-activerecord dependency floor to >=1.0.0.dev0 - Fix relation/derived bridge imports to correctly named testsuite modules - Add changelog fragment
1 parent 6857232 commit 77e3f00

7 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎changelog.d/23a6c91.added.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `--scenarios` option support: scenario filtering now reads the generic `TESTSUITE_ACTIVE_SCENARIOS` env var (or the backend-local `SQLSERVER_ACTIVE_SCENARIOS`) so tests run consistently from both the testsuite directory and the backend's own `tests/` directory. Raised the core dependency floor to `rhosocial-activerecord>=1.0.0.dev0`.

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ classifiers = [
3535
]
3636
dependencies = [
3737
"pyodbc>=5.3.0",
38-
"rhosocial-activerecord",
38+
"rhosocial-activerecord>=1.0.0.dev0,<2.0.0",
3939
]
4040

4141
[project.scripts]

‎tests/providers/scenarios.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,37 @@ def _load_scenarios_from_config():
4747
for scenario_name, config in config_data['scenarios'].items():
4848
register_scenario(scenario_name, config)
4949

50+
_apply_scenario_filter()
51+
5052
except ImportError:
5153
raise ImportError("PyYAML is required to load SQL Server scenario configuration files")
5254

5355

56+
def _apply_scenario_filter():
57+
"""Filter SCENARIO_MAP based on the active scenarios env var.
58+
59+
The env var is set either by the --scenarios pytest option in the
60+
testsuite's root conftest (TESTSUITE_ACTIVE_SCENARIOS) or by a backend
61+
local override (SQLSERVER_ACTIVE_SCENARIOS). It contains comma-separated
62+
full scenario names (e.g., "sqlserver_2022,sqlserver_2019").
63+
"""
64+
filter_str = os.getenv("SQLSERVER_ACTIVE_SCENARIOS") or os.getenv("TESTSUITE_ACTIVE_SCENARIOS")
65+
if not filter_str:
66+
return
67+
68+
allowed = set(s.strip() for s in filter_str.split(',') if s.strip())
69+
if not allowed:
70+
return
71+
72+
to_remove = [name for name in SCENARIO_MAP if name not in allowed]
73+
for name in to_remove:
74+
del SCENARIO_MAP[name]
75+
76+
if to_remove:
77+
print(f"Filtered scenarios: kept {list(SCENARIO_MAP.keys())}, "
78+
f"removed {to_remove} (--scenarios={filter_str})")
79+
80+
5481
def _register_default_scenarios():
5582
_load_scenarios_from_config()
5683

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# tests/rhosocial/activerecord_sqlserver_test/feature/relation/derived/test_derived_field.py
22
"""Bridge file for sync relation derived field tests."""
3-
from rhosocial.activerecord.testsuite.feature.relation.derived.test_derived_field import * # noqa: F401, F403, E402
3+
from rhosocial.activerecord.testsuite.feature.relation.derived.test_relation_derived_field import * # noqa: F401, F403, E402
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# tests/rhosocial/activerecord_sqlserver_test/feature/relation/derived/test_derived_field_async.py
22
"""Bridge file for async relation derived field tests."""
3-
from rhosocial.activerecord.testsuite.feature.relation.derived.test_derived_field_async import * # noqa: F401, F403, E402
3+
from rhosocial.activerecord.testsuite.feature.relation.derived.test_relation_derived_field_async import * # noqa: F401, F403, E402
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# tests/rhosocial/activerecord_sqlserver_test/feature/relation/derived/test_derived_field_json.py
22
"""Bridge file for JSON-derived field tests."""
3-
from rhosocial.activerecord.testsuite.feature.relation.derived.test_derived_field_json import * # noqa: F401, F403, E402
4-
from rhosocial.activerecord.testsuite.feature.relation.derived.test_derived_field_json_async import * # noqa: F403, E402
3+
from rhosocial.activerecord.testsuite.feature.relation.derived.test_relation_derived_field_json import * # noqa: F401, F403, E402
4+
from rhosocial.activerecord.testsuite.feature.relation.derived.test_relation_derived_field_json_async import * # noqa: F403, E402
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# tests/rhosocial/activerecord_sqlserver_test/feature/relation/derived/test_derived_field_json_async.py
22
"""Bridge file for async JSON-derived field tests."""
3-
from rhosocial.activerecord.testsuite.feature.relation.derived.test_derived_field_json_async import * # noqa: F401, F403, E402
3+
from rhosocial.activerecord.testsuite.feature.relation.derived.test_relation_derived_field_json_async import * # noqa: F401, F403, E402

0 commit comments

Comments
 (0)