datasecops-cli 0.8.0b1__tar.gz → 0.8.0b3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/CHANGELOG.md +18 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/PKG-INFO +5 -1
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/README.md +4 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/pyproject.toml +1 -1
- datasecops_cli-0.8.0b3/src/datasecops_cli/__init__.py +1 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/main.py +15 -44
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/menus/development.py +2 -2
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/linting_service.py +18 -12
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_linting_service.py +68 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_main.py +17 -22
- datasecops_cli-0.8.0b1/src/datasecops_cli/__init__.py +0 -1
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/.github/workflows/auto-tag.yml +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/.github/workflows/publish-cli.yml +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/.github/workflows/test.yml +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/.gitignore +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/AGENTS.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/DEVELOPMENT.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/LICENSE +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/docs/getting-started.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/docs/git-operations.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/docs/legacy.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/docs/legacy_plan_of_action.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/docs/mcp-server.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/docs/squash-merge-into-test-review.md +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/mcp-servers.json +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/setup.ps1 +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/setup.sh +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/config.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/menus/__init__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/menus/configuration.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/menus/downloads.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/menus/git_operations.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/models/__init__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/models/git_helpers.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/models/project_config.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/__init__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/bootstrap_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/dbt_project_generator.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/dbt_runner.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/directory_scaffolder.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/download_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/git_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/pipeline_env.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/skill_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/snowflake_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/upstream_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/__init__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/display.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/file_utils.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/mcp.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/yaml_utils.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_mcp/__init__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_mcp/__main__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_mcp/connection.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_mcp/server.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/__init__.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_config.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_dbt_project_generator_profiles.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_dbt_project_generator_yml.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_dbt_runner.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_directory_scaffolder.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_download_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_file_utils.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_git_operations_menu.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_git_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_mcp_branching_rules.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_mcp_lint_tools.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_models.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_pipeline_env.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_upstream_service.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_version.py +0 -0
- {datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_yaml_utils.py +0 -0
|
@@ -4,6 +4,22 @@ All notable changes to the DataSecOps CLI are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.8.0b3] - 2026-11-24
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Linting a specific file by model/object name only looked under `models/`** — `resolve_model_path()`
|
|
12
|
+
(used by the interactive menu's `lint → specific` and `format → specific` options) only globbed
|
|
13
|
+
`models/*.sql`, so a name resolving to a stored procedure, UDF, task, alert, stage, file format or
|
|
14
|
+
DMF under `objects/` couldn't be found. It now searches `models/` first and falls back to `objects/`
|
|
15
|
+
only when nothing matches there, so a model/object basename collision still resolves to the model.
|
|
16
|
+
- **`dbt_project_dir` was doubled up (e.g. `./dbt/dbt`) when the CLI was run with its working
|
|
17
|
+
directory already set to the dbt project folder** — `_connect_and_load()` always appended the
|
|
18
|
+
framework's configured dbt subpath (`project_settings.project_dir`, default `./dbt`) onto
|
|
19
|
+
`project_dir`, even when `project_dir` already pointed directly at the dbt project. This made
|
|
20
|
+
downloads like `.sqlfluff` get written into a nonexistent nested `dbt/dbt` folder. It now checks
|
|
21
|
+
whether `dbt_project.yml` already exists directly under `project_dir` before appending the subpath.
|
|
22
|
+
|
|
7
23
|
### Removed
|
|
8
24
|
|
|
9
25
|
- **All DCM (Database Change Management) support moved to the Meridian CLI** (`pip install meridian-cli`, command
|
|
@@ -11,6 +27,8 @@ All notable changes to the DataSecOps CLI are documented in this file.
|
|
|
11
27
|
the `datasecops dcm ...` and `datasecops model ...` commands, `download dcm`, the DCM menu, bootstrap's DCM
|
|
12
28
|
scaffold, `.datasecops.yml`'s `dcm_*` keys, the `datasecops_model` package, `scripts/vendor_model.py`, `docs/dcm.md`
|
|
13
29
|
and the DCM MCP tools. `datasecops-cli` is dbt only.
|
|
30
|
+
- **CoCo main menu option** — the interactive menu no longer has an option to launch CoCo directly.
|
|
31
|
+
Remaining options are renumbered (`configure` is now `[3]`, `downloads` `[4]`, `bootstrap` `[5]`, `update pkgs` `[6]`).
|
|
14
32
|
|
|
15
33
|
## [0.7.0b17] - 2026-11-05
|
|
16
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datasecops-cli
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.0b3
|
|
4
4
|
Summary: DataSecOps Framework CLI for Snowflake Native App
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -108,6 +108,10 @@ The Development menu exposes these flags from the underlying `dbt` commands:
|
|
|
108
108
|
These are not available on the SQLFluff (dbt Core 1.x) path; on dbt Core the CLI skips
|
|
109
109
|
`--generate-info-schema`/`--static-analysis strict` with a warning instead of sending a flag
|
|
110
110
|
dbt Core would reject.
|
|
111
|
+
- **`lint` → `specific`** *(both engines)*, **`format` → `specific`** *(dbt2 engine only)* -
|
|
112
|
+
resolve a bare name (e.g. `stg_orders`) by searching `models/` first, then `objects/`
|
|
113
|
+
(stored procedures, UDFs, tasks, alerts, stages, file formats, DMFs) if nothing matched
|
|
114
|
+
under `models/`.
|
|
111
115
|
|
|
112
116
|
## Non-Interactive Mode (CI/CD)
|
|
113
117
|
|
|
@@ -87,6 +87,10 @@ The Development menu exposes these flags from the underlying `dbt` commands:
|
|
|
87
87
|
These are not available on the SQLFluff (dbt Core 1.x) path; on dbt Core the CLI skips
|
|
88
88
|
`--generate-info-schema`/`--static-analysis strict` with a warning instead of sending a flag
|
|
89
89
|
dbt Core would reject.
|
|
90
|
+
- **`lint` → `specific`** *(both engines)*, **`format` → `specific`** *(dbt2 engine only)* -
|
|
91
|
+
resolve a bare name (e.g. `stg_orders`) by searching `models/` first, then `objects/`
|
|
92
|
+
(stored procedures, UDFs, tasks, alerts, stages, file formats, DMFs) if nothing matched
|
|
93
|
+
under `models/`.
|
|
90
94
|
|
|
91
95
|
## Non-Interactive Mode (CI/CD)
|
|
92
96
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.8.0b3"
|
|
@@ -670,8 +670,14 @@ def _connect_and_load(config: Config, interactive: bool = True,
|
|
|
670
670
|
# The framework's PROJECT config is the authoritative location for the dbt project —
|
|
671
671
|
# trust it even if the project hasn't been scaffolded there yet (e.g. running
|
|
672
672
|
# `download packages` before `bootstrap`), so downstream commands (packages.yml,
|
|
673
|
-
# dbt deps, etc.) never silently fall back to the project root.
|
|
674
|
-
|
|
673
|
+
# dbt deps, etc.) never silently fall back to the project root. But if the CLI is
|
|
674
|
+
# already being run with its working directory set to the dbt project itself
|
|
675
|
+
# (dbt_project.yml exists directly there), don't append the framework's subpath
|
|
676
|
+
# again — that would double it up (e.g. ./dbt/dbt).
|
|
677
|
+
if (config.project_dir / "dbt_project.yml").exists():
|
|
678
|
+
config.dbt_project_dir = config.project_dir
|
|
679
|
+
else:
|
|
680
|
+
config.dbt_project_dir = config.project_dir / config.project_settings.project_dir
|
|
675
681
|
|
|
676
682
|
if not config.profile:
|
|
677
683
|
error_line(f"Profile '{config.profile_name}' not found in native app")
|
|
@@ -879,40 +885,6 @@ def _main_menu(config: Config, dbt_runner: DbtRunner, git_service: GitService,
|
|
|
879
885
|
git_menu.show()
|
|
880
886
|
|
|
881
887
|
elif option == 3:
|
|
882
|
-
display_action_header("Launch CoCo")
|
|
883
|
-
try:
|
|
884
|
-
import json as _json
|
|
885
|
-
from datasecops_cli.utilities.display import get_input_true_false as _confirm
|
|
886
|
-
conn = config.datasecops.connection_name
|
|
887
|
-
cortex_conn = config.datasecops.cortex_connection or conn
|
|
888
|
-
|
|
889
|
-
# Check current agent connection from CoCo settings
|
|
890
|
-
cortex_settings_path = Path.home() / ".snowflake" / "cortex" / "settings.json"
|
|
891
|
-
if cortex_settings_path.exists():
|
|
892
|
-
settings = _json.loads(cortex_settings_path.read_text(encoding="utf-8"))
|
|
893
|
-
current_agent_conn = settings.get("cortexAgentConnectionName", "")
|
|
894
|
-
if current_agent_conn and current_agent_conn != cortex_conn:
|
|
895
|
-
warning_line(f"CoCo agent connection is '{current_agent_conn}', "
|
|
896
|
-
f"but cortex_connection in .datasecops.yml is '{cortex_conn}'")
|
|
897
|
-
if _confirm(f"Update agent connection to '{cortex_conn}'?", default="y"):
|
|
898
|
-
settings["cortexAgentConnectionName"] = cortex_conn
|
|
899
|
-
cortex_settings_path.write_text(
|
|
900
|
-
_json.dumps(settings, indent=2), encoding="utf-8")
|
|
901
|
-
success_line(f"Agent connection updated to: {cortex_conn}")
|
|
902
|
-
else:
|
|
903
|
-
cortex_conn = current_agent_conn
|
|
904
|
-
info_line(f"Keeping agent connection: {cortex_conn}")
|
|
905
|
-
|
|
906
|
-
# Set SQL connection
|
|
907
|
-
info_line(f"SQL connection: {conn}")
|
|
908
|
-
info_line(f"Agent connection: {cortex_conn}")
|
|
909
|
-
# Launch with --connection to set agent connection
|
|
910
|
-
subprocess.run(["cortex", "--connection", conn])
|
|
911
|
-
except FileNotFoundError:
|
|
912
|
-
error_line("CoCo CLI not found. Install it from: https://docs.snowflake.com/en/user-guide/cortex-code")
|
|
913
|
-
complete_action()
|
|
914
|
-
|
|
915
|
-
elif option == 4:
|
|
916
888
|
config_menu = ConfigurationMenu(
|
|
917
889
|
download_service, linting_service,
|
|
918
890
|
profile_name, config.dbt_project_dir,
|
|
@@ -924,7 +896,7 @@ def _main_menu(config: Config, dbt_runner: DbtRunner, git_service: GitService,
|
|
|
924
896
|
)
|
|
925
897
|
config_menu.show()
|
|
926
898
|
|
|
927
|
-
elif option ==
|
|
899
|
+
elif option == 4:
|
|
928
900
|
dl_menu = DownloadsMenu(
|
|
929
901
|
download_service, skill_service, dbt_runner,
|
|
930
902
|
profile_name, config.dbt_project_dir,
|
|
@@ -936,7 +908,7 @@ def _main_menu(config: Config, dbt_runner: DbtRunner, git_service: GitService,
|
|
|
936
908
|
)
|
|
937
909
|
dl_menu.show()
|
|
938
910
|
|
|
939
|
-
elif option ==
|
|
911
|
+
elif option == 5:
|
|
940
912
|
from datasecops_cli.utilities.display import get_input_true_false, select_multiple_from_list
|
|
941
913
|
platform = config.source_control.source_control_platform.lower()
|
|
942
914
|
info_line(f"Platform: {platform}")
|
|
@@ -961,7 +933,7 @@ def _main_menu(config: Config, dbt_runner: DbtRunner, git_service: GitService,
|
|
|
961
933
|
error_line(f"Bootstrap failed: {e}")
|
|
962
934
|
complete_action()
|
|
963
935
|
|
|
964
|
-
elif option ==
|
|
936
|
+
elif option == 6 and has_outdated:
|
|
965
937
|
_update_upstream_packages(config, dbt_runner, upstream_statuses)
|
|
966
938
|
# Refresh upstream statuses after update
|
|
967
939
|
from datasecops_cli.services.upstream_service import check_upstream_versions
|
|
@@ -986,12 +958,11 @@ def _show_main_menu(profile_name: str, git_service: GitService = None,
|
|
|
986
958
|
upstream_info=upstream_statuses)
|
|
987
959
|
menu_option(1, "development - dbt Development Commands")
|
|
988
960
|
menu_option(2, "git - Source Control Operations")
|
|
989
|
-
menu_option(3, "
|
|
990
|
-
menu_option(4, "
|
|
991
|
-
menu_option(5, "
|
|
992
|
-
menu_option(6, "bootstrap - Set up a new dbt project with all framework config")
|
|
961
|
+
menu_option(3, "configure - Install tools, MCP servers & project setup")
|
|
962
|
+
menu_option(4, "downloads - Download Configs & Skills")
|
|
963
|
+
menu_option(5, "bootstrap - Set up a new dbt project with all framework config")
|
|
993
964
|
if upstream_statuses and any(s.needs_update for s in upstream_statuses):
|
|
994
|
-
menu_option(
|
|
965
|
+
menu_option(6, "update pkgs - Update upstream packages to latest versions")
|
|
995
966
|
menu_option(0, "exit - Exit")
|
|
996
967
|
|
|
997
968
|
|
|
@@ -359,7 +359,7 @@ class DevelopmentMenu:
|
|
|
359
359
|
exclude_rules=exclude_rules,
|
|
360
360
|
jinja_render_mode=jinja_render_mode)
|
|
361
361
|
else:
|
|
362
|
-
error_line(f"Could not find model '{name}' in models/
|
|
362
|
+
error_line(f"Could not find model '{name}' in models/ or objects/")
|
|
363
363
|
elif option == 4:
|
|
364
364
|
if not self.downloads:
|
|
365
365
|
error_line("Download service not available")
|
|
@@ -377,7 +377,7 @@ class DevelopmentMenu:
|
|
|
377
377
|
if name:
|
|
378
378
|
path = name if name.endswith(".sql") else self.linting.resolve_model_path(name)
|
|
379
379
|
if not path:
|
|
380
|
-
error_line(f"Could not find model '{name}' in models/
|
|
380
|
+
error_line(f"Could not find model '{name}' in models/ or objects/")
|
|
381
381
|
complete_action()
|
|
382
382
|
continue
|
|
383
383
|
check = get_input_true_false(
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/linting_service.py
RENAMED
|
@@ -100,18 +100,24 @@ class LintingService:
|
|
|
100
100
|
return self.install_requirements(missing)
|
|
101
101
|
|
|
102
102
|
def resolve_model_path(self, name: str) -> str | None:
|
|
103
|
-
"""Resolve a model name (e.g. 'stg_orders') to its SQL file path
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
"""Resolve a model/object name (e.g. 'stg_orders') to its SQL file path.
|
|
104
|
+
|
|
105
|
+
Searches models/ first, then falls back to objects/ (stored procedures, UDFs,
|
|
106
|
+
tasks, alerts, stages, file formats, DMFs) only if nothing matched under models/,
|
|
107
|
+
so a model name that happens to collide with an object's basename still resolves.
|
|
108
|
+
"""
|
|
109
|
+
for subdir in ("models", "objects"):
|
|
110
|
+
search_dir = self.project_dir / subdir
|
|
111
|
+
if not search_dir.exists():
|
|
112
|
+
continue
|
|
113
|
+
matches = list(search_dir.rglob(f"{name}.sql"))
|
|
114
|
+
if len(matches) == 1:
|
|
115
|
+
return str(matches[0].relative_to(self.project_dir))
|
|
116
|
+
if len(matches) > 1:
|
|
117
|
+
warning_line(f"Multiple matches for '{name}':")
|
|
118
|
+
for m in matches:
|
|
119
|
+
info_line(f" {m.relative_to(self.project_dir)}")
|
|
120
|
+
return None
|
|
115
121
|
return None
|
|
116
122
|
|
|
117
123
|
def lint_file(self, file_path: str = None, fix: bool = False, rules: str = None,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Tests for engine-conditional logic in datasecops_cli.services.linting_service."""
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
from unittest.mock import patch, MagicMock
|
|
3
4
|
|
|
4
5
|
from datasecops_cli.services.linting_service import LintingService
|
|
@@ -155,3 +156,70 @@ class TestEnsureTemplaterInstalled:
|
|
|
155
156
|
result = service.ensure_templater_installed(required_packages=["sqlfluff==3.4.0"])
|
|
156
157
|
assert result is True
|
|
157
158
|
mock_run.assert_not_called()
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class TestResolveModelPath:
|
|
162
|
+
def test_finds_model_under_models(self, tmp_path):
|
|
163
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
164
|
+
staging = tmp_path / "models" / "staging"
|
|
165
|
+
staging.mkdir(parents=True)
|
|
166
|
+
(staging / "stg_orders.sql").write_text("select 1")
|
|
167
|
+
|
|
168
|
+
path = service.resolve_model_path("stg_orders")
|
|
169
|
+
assert path == str(Path("models") / "staging" / "stg_orders.sql")
|
|
170
|
+
|
|
171
|
+
def test_finds_object_under_objects(self, tmp_path):
|
|
172
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
173
|
+
procs = tmp_path / "objects" / "stored_procedures"
|
|
174
|
+
procs.mkdir(parents=True)
|
|
175
|
+
(procs / "sp_refresh.sql").write_text("call sp_refresh()")
|
|
176
|
+
|
|
177
|
+
path = service.resolve_model_path("sp_refresh")
|
|
178
|
+
assert path == str(Path("objects") / "stored_procedures" / "sp_refresh.sql")
|
|
179
|
+
|
|
180
|
+
def test_model_takes_priority_over_object_with_same_basename(self, tmp_path):
|
|
181
|
+
"""A model and an object sharing a basename must still resolve (to the model),
|
|
182
|
+
not be reported as ambiguous."""
|
|
183
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
184
|
+
models_dir = tmp_path / "models"
|
|
185
|
+
models_dir.mkdir()
|
|
186
|
+
(models_dir / "shared.sql").write_text("select 1")
|
|
187
|
+
objects_dir = tmp_path / "objects" / "tasks"
|
|
188
|
+
objects_dir.mkdir(parents=True)
|
|
189
|
+
(objects_dir / "shared.sql").write_text("create task shared ...")
|
|
190
|
+
|
|
191
|
+
path = service.resolve_model_path("shared")
|
|
192
|
+
assert path == str(Path("models") / "shared.sql")
|
|
193
|
+
|
|
194
|
+
def test_returns_none_when_no_match(self, tmp_path):
|
|
195
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
196
|
+
(tmp_path / "models").mkdir()
|
|
197
|
+
(tmp_path / "objects").mkdir()
|
|
198
|
+
|
|
199
|
+
assert service.resolve_model_path("does_not_exist") is None
|
|
200
|
+
|
|
201
|
+
def test_returns_none_when_neither_directory_exists(self, tmp_path):
|
|
202
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
203
|
+
assert service.resolve_model_path("anything") is None
|
|
204
|
+
|
|
205
|
+
def test_ambiguous_match_within_models_returns_none(self, tmp_path):
|
|
206
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
207
|
+
a = tmp_path / "models" / "a"
|
|
208
|
+
b = tmp_path / "models" / "b"
|
|
209
|
+
a.mkdir(parents=True)
|
|
210
|
+
b.mkdir(parents=True)
|
|
211
|
+
(a / "dup.sql").write_text("select 1")
|
|
212
|
+
(b / "dup.sql").write_text("select 2")
|
|
213
|
+
|
|
214
|
+
assert service.resolve_model_path("dup") is None
|
|
215
|
+
|
|
216
|
+
def test_ambiguous_match_within_objects_returns_none(self, tmp_path):
|
|
217
|
+
service = LintingService(tmp_path, dbt_engine="dbt2")
|
|
218
|
+
a = tmp_path / "objects" / "tasks"
|
|
219
|
+
b = tmp_path / "objects" / "alerts"
|
|
220
|
+
a.mkdir(parents=True)
|
|
221
|
+
b.mkdir(parents=True)
|
|
222
|
+
(a / "dup.sql").write_text("create task dup ...")
|
|
223
|
+
(b / "dup.sql").write_text("create alert dup ...")
|
|
224
|
+
|
|
225
|
+
assert service.resolve_model_path("dup") is None
|
|
@@ -403,9 +403,24 @@ class TestConnectAndLoad:
|
|
|
403
403
|
|
|
404
404
|
assert config.dbt_project_dir == dbt_dir
|
|
405
405
|
|
|
406
|
+
def test_does_not_double_up_when_cwd_is_already_dbt_dir(self, tmp_path, monkeypatch):
|
|
407
|
+
"""If the CLI is run with its working directory already set to the dbt project
|
|
408
|
+
(dbt_project.yml exists directly there), dbt_project_dir must not get the
|
|
409
|
+
framework's './dbt' subpath appended again (e.g. ./dbt/dbt)."""
|
|
410
|
+
self._write_datasecops_yml(tmp_path)
|
|
411
|
+
(tmp_path / "dbt_project.yml").write_text("name: proj\nprofile: p\n", encoding="utf-8")
|
|
412
|
+
monkeypatch.chdir(tmp_path)
|
|
413
|
+
config = Config()
|
|
414
|
+
|
|
415
|
+
mock_sf = self._mock_snowflake_service()
|
|
416
|
+
with patch("datasecops_cli.main.SnowflakeService", return_value=mock_sf):
|
|
417
|
+
_connect_and_load(config)
|
|
418
|
+
|
|
419
|
+
assert config.dbt_project_dir == tmp_path
|
|
420
|
+
|
|
406
421
|
|
|
407
422
|
class TestMainMenuBootstrapOption:
|
|
408
|
-
"""Regression tests for option [
|
|
423
|
+
"""Regression tests for option [5] bootstrap in the interactive main menu."""
|
|
409
424
|
|
|
410
425
|
def _make_config(self):
|
|
411
426
|
config = Config()
|
|
@@ -419,7 +434,7 @@ class TestMainMenuBootstrapOption:
|
|
|
419
434
|
config = self._make_config()
|
|
420
435
|
|
|
421
436
|
monkeypatch.setattr("datasecops_cli.utilities.display.get_input_true_false", lambda *a, **k: False)
|
|
422
|
-
with patch("datasecops_cli.main.get_input_number", side_effect=[
|
|
437
|
+
with patch("datasecops_cli.main.get_input_number", side_effect=[5, 0]), \
|
|
423
438
|
patch("datasecops_cli.main.BootstrapService") as MockBootstrap, \
|
|
424
439
|
patch("datasecops_cli.main._show_main_menu"), \
|
|
425
440
|
patch("datasecops_cli.main.error_line") as mock_error, \
|
|
@@ -433,26 +448,6 @@ class TestMainMenuBootstrapOption:
|
|
|
433
448
|
assert "boom" in mock_error.call_args.args[0]
|
|
434
449
|
mock_complete.assert_called_once()
|
|
435
450
|
|
|
436
|
-
def test_coco_then_bootstrap_does_not_crash(self, tmp_path, monkeypatch):
|
|
437
|
-
"""Launching CoCo (option 3, missing executable) before bootstrap (option 6) must
|
|
438
|
-
not raise UnboundLocalError from a branch-local import shadowing complete_action."""
|
|
439
|
-
config = self._make_config()
|
|
440
|
-
|
|
441
|
-
monkeypatch.setattr("datasecops_cli.utilities.display.get_input_true_false", lambda *a, **k: False)
|
|
442
|
-
with patch("datasecops_cli.main.get_input_number", side_effect=[3, 6, 0]), \
|
|
443
|
-
patch("datasecops_cli.main.subprocess.run", side_effect=FileNotFoundError), \
|
|
444
|
-
patch("datasecops_cli.main.Path.home", return_value=tmp_path), \
|
|
445
|
-
patch("datasecops_cli.main.BootstrapService") as MockBootstrap, \
|
|
446
|
-
patch("datasecops_cli.main._show_main_menu"), \
|
|
447
|
-
patch("datasecops_cli.main.complete_action") as mock_complete:
|
|
448
|
-
MockBootstrap.return_value.run.return_value = True
|
|
449
|
-
|
|
450
|
-
_main_menu(config, MagicMock(), None, MagicMock(), MagicMock(),
|
|
451
|
-
MagicMock(), MagicMock())
|
|
452
|
-
|
|
453
|
-
# Once for the missing-CoCo message, once after bootstrap
|
|
454
|
-
assert mock_complete.call_count == 2
|
|
455
|
-
|
|
456
451
|
|
|
457
452
|
class TestDownloadPackageFiltering:
|
|
458
453
|
"""Tests for dbt package filtering by profile."""
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.8.0b1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/menus/git_operations.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/models/project_config.py
RENAMED
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/bootstrap_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/download_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/git_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/pipeline_env.py
RENAMED
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/skill_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/snowflake_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/services/upstream_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/file_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/src/datasecops_cli/utilities/yaml_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.8.0b1 → datasecops_cli-0.8.0b3}/tests/test_dbt_project_generator_profiles.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|