Skip to content

Commit 613d50f

Browse files
committed
SNOW-2306184: config refactor - cleanup 5
1 parent 355b796 commit 613d50f

File tree

5 files changed

+23
-62
lines changed

5 files changed

+23
-62
lines changed

tests/conftest.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,11 @@ def matches(
8989
)
9090

9191

92-
class ConfigModeSnapshotExtension(AmberSnapshotExtension):
93-
"""Snapshot extension that includes config mode in snapshot file name."""
94-
95-
@classmethod
96-
def _get_file_basename(cls, *, test_location, index):
97-
"""Generate snapshot filename with config mode suffix."""
98-
config_mode = (
99-
"config_ng" if os.getenv("SNOWFLAKE_CLI_CONFIG_V2_ENABLED") else "legacy"
100-
)
101-
basename = super()._get_file_basename(test_location=test_location, index=index)
102-
# Insert config mode before .ambr extension
103-
return f"{basename}_{config_mode}"
104-
105-
10692
@pytest.fixture()
10793
def os_agnostic_snapshot(snapshot):
10894
return snapshot.use_extension(CustomSnapshotExtension)
10995

11096

111-
@pytest.fixture()
112-
def config_snapshot(snapshot):
113-
"""Config-mode-aware snapshot fixture for tests that differ between legacy and config_ng."""
114-
return snapshot.use_extension(ConfigModeSnapshotExtension)
115-
116-
11797
@pytest.fixture(autouse=True)
11898
# Global context and logging levels reset is required.
11999
# Without it, state from previous tests is visible in following tests.

tests_common/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
from tests_common.path_utils import *
1818

1919
IS_WINDOWS = platform.system() == "Windows"
20+
21+
__all__ = ["IS_WINDOWS", "ConfigModeSnapshotExtension", "config_snapshot"]

tests_common/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import pytest
2525
import yaml
26+
from syrupy.extensions.amber import AmberSnapshotExtension
2627

2728
from snowflake.cli._plugins.streamlit.streamlit_entity import StreamlitEntity
2829
from snowflake.cli._plugins.streamlit.streamlit_entity_model import StreamlitEntityModel
@@ -144,3 +145,23 @@ def _update(snowflake_yml_path: Path, parameter_path: str, value=None):
144145
sys.version_info >= PYTHON_3_12,
145146
reason="requires python3.11 or lower",
146147
)
148+
149+
150+
class ConfigModeSnapshotExtension(AmberSnapshotExtension):
151+
"""Snapshot extension that includes config mode in snapshot file name."""
152+
153+
@classmethod
154+
def _get_file_basename(cls, *, test_location, index):
155+
"""Generate snapshot filename with config mode suffix."""
156+
config_mode = (
157+
"config_ng" if os.getenv("SNOWFLAKE_CLI_CONFIG_V2_ENABLED") else "legacy"
158+
)
159+
basename = super()._get_file_basename(test_location=test_location, index=index)
160+
# Insert config mode before .ambr extension
161+
return f"{basename}_{config_mode}"
162+
163+
164+
@pytest.fixture()
165+
def config_snapshot(snapshot):
166+
"""Config-mode-aware snapshot fixture for tests that differ between legacy and config_ng."""
167+
return snapshot.use_extension(ConfigModeSnapshotExtension)

tests_e2e/conftest.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from snowflake.cli import __about__
2626
from snowflake.cli.api.constants import PYTHON_3_12
2727
from snowflake.cli.api.secure_path import SecurePath
28-
from syrupy.extensions.amber import AmberSnapshotExtension
2928

3029
from tests_common import IS_WINDOWS
3130

@@ -36,26 +35,6 @@
3635
]
3736

3837

39-
class ConfigModeSnapshotExtension(AmberSnapshotExtension):
40-
"""Snapshot extension that includes config mode in snapshot file name."""
41-
42-
@classmethod
43-
def _get_file_basename(cls, *, test_location, index):
44-
"""Generate snapshot filename with config mode suffix."""
45-
config_mode = (
46-
"config_ng" if os.getenv("SNOWFLAKE_CLI_CONFIG_V2_ENABLED") else "legacy"
47-
)
48-
basename = super()._get_file_basename(test_location=test_location, index=index)
49-
# Insert config mode before .ambr extension
50-
return f"{basename}_{config_mode}"
51-
52-
53-
@pytest.fixture()
54-
def config_snapshot(snapshot):
55-
"""Config-mode-aware snapshot fixture for tests that differ between legacy and config_ng."""
56-
return snapshot.use_extension(ConfigModeSnapshotExtension)
57-
58-
5938
def _clean_output(text: str):
6039
"""
6140
Replacing util to clean up console output. Typer is using rich.Panel to show the --help content.

tests_integration/conftest.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
import pytest
3333
import yaml
34-
from syrupy.extensions.amber import AmberSnapshotExtension
3534
from typer import Typer
3635
from typer.testing import CliRunner
3736

@@ -56,26 +55,6 @@
5655
]
5756

5857

59-
class ConfigModeSnapshotExtension(AmberSnapshotExtension):
60-
"""Snapshot extension that includes config mode in snapshot file name."""
61-
62-
@classmethod
63-
def _get_file_basename(cls, *, test_location, index):
64-
"""Generate snapshot filename with config mode suffix."""
65-
config_mode = (
66-
"config_ng" if os.getenv("SNOWFLAKE_CLI_CONFIG_V2_ENABLED") else "legacy"
67-
)
68-
basename = super()._get_file_basename(test_location=test_location, index=index)
69-
# Insert config mode before .ambr extension
70-
return f"{basename}_{config_mode}"
71-
72-
73-
@pytest.fixture()
74-
def config_snapshot(snapshot):
75-
"""Config-mode-aware snapshot fixture for tests that differ between legacy and config_ng."""
76-
return snapshot.use_extension(ConfigModeSnapshotExtension)
77-
78-
7958
TEST_DIR = Path(__file__).parent
8059
DEFAULT_TEST_CONFIG = "connection_configs.toml"
8160
WORLD_READABLE_CONFIG = "world_readable.toml"

0 commit comments

Comments
 (0)