bmsdna-devtools 1.1.1__tar.gz → 1.2.0__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.
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/PKG-INFO +6 -2
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/README.md +4 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/ci_plan.py +40 -14
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/prek.toml +3 -3
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/pyproject.toml +8 -4
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/fake_github.py +13 -9
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_api_usage.py +2 -1
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_ci_plan.py +77 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_ci_plan_env.py +14 -10
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_deps_osv.py +28 -20
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_deps_versions.py +3 -2
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_find_repo.py +16 -10
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_gh_issue.py +2 -2
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_gh_pr.py +11 -12
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_issue_for_me.py +1 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_logs.py +5 -3
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_build_flow.py +2 -2
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_choice.py +7 -7
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_info.py +4 -3
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_list.py +3 -3
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pull.py +2 -2
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_wait_timeout.py +7 -7
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/uv.lock +56 -49
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/.github/workflows/auto-release.yml +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/.github/workflows/python-publish.yml +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/.github/workflows/python-test.yml +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/.gitignore +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/.python-version +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/__init__.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/_api_dump.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/ado_auth.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/ado_issue.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/agent_mentions.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/api_usage.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/app_service_logs.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/azure_arm.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/azure_auth.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/bdt_config.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/business_user.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/ci_plan_env.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/cli.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/cli_tools.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/commit.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/dead_code.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/__init__.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/advisories.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/cli.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/cooldown.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/lockfiles.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/osv.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/deps/versions.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/env_config.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/env_files.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/find_injection.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/find_repo.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/gh_args.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/gh_issue.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/gh_pr.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/github_api.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/gitrepo.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/injection_frontend.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/injection_python.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/issue_do.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/issue_show.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/issue_watch.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint_findings.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint_models.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint_sql.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint_sql_files.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint_tooling.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/lint_typescript.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/logs.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_build.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_cancel.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_choice.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_create_args.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_drift.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_info.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_issue_link.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_labels.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_list.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_markdown.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pr_ref.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/pull.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/testdb.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/translate.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/__init__.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/cli.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/pipeline.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/pricing.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/report.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/bmsdna/devtools/worktree.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/justfile +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/skills/bmsdna-devtools/SKILL.md +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/conftest.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_ado_auth.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_ado_issue.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_ado_issue_flow.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_agent_mentions.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_app_service_logs.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_azure_arm.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_bdt_config.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_business_user.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_cleanup.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_commit.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_deps.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_issue.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_pr_create.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_pr_id.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_pull.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_tools.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_cli_version.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_commit.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_deps_advisories.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_deps_cooldown.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_deps_lockfiles.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_env_config.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_env_files.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_find_injection.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_github_api.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_gitrepo.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_issue_do.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_issue_show.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_issue_watch.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_lint.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_lint_models.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_lint_sql.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_lint_sql_files.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_lint_tooling.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_lint_typescript.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_build.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_build_create_options.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_cancel_build.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_create_args.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_description_not_truncated.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_drift.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_issue_link.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_labels.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_markdown.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_pr_merge_defaults.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_testdb.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_translate.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_usage.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_worktree_clean.py +0 -0
- {bmsdna_devtools-1.1.1 → bmsdna_devtools-1.2.0}/tests/test_worktree_create.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bmsdna-devtools
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
|
|
5
5
|
Requires-Python: >=3.14
|
|
6
6
|
Requires-Dist: azure-identity>=1.19.0
|
|
7
7
|
Requires-Dist: packaging>=24.0
|
|
8
|
-
Requires-Dist: pgdevkit[db]>=0.
|
|
8
|
+
Requires-Dist: pgdevkit[db]>=0.19.0
|
|
9
9
|
Requires-Dist: requests>=2.32.0
|
|
10
10
|
Requires-Dist: rich>=13.0.0
|
|
11
11
|
Requires-Dist: tomli-w>=1.0.0
|
|
@@ -968,6 +968,10 @@ dir = "tests/unit" # areas = sub-folders with tests (test_*.py / *_
|
|
|
968
968
|
dir = "tests/e2e" # flat folder: map the test_*.py files to areas instead
|
|
969
969
|
areas = { chat = ["test_chat*.py"], review = ["test_review_*.py"] } # unmatched files form the area `shared`
|
|
970
970
|
|
|
971
|
+
[tool.bdt.ci.plan.tiers.browser]
|
|
972
|
+
dir = "e2e/tests" # another runner: `test_files` says what a test file is (default ["test_*.py", "*_test.py"])
|
|
973
|
+
test_files = ["*.spec.ts"] # Playwright: e2e/tests/<area>/*.spec.ts, run per area with `playwright test e2e/tests/<area>`
|
|
974
|
+
|
|
971
975
|
[tool.bdt.ci.plan.paths] # non-test files an area owns: changing them infers that area instead of everything
|
|
972
976
|
infra = ["infra/**"] # built-in default when the repo has an infra/ folder; add e.g. frontend = ["frontend/**"]
|
|
973
977
|
```
|
|
@@ -949,6 +949,10 @@ dir = "tests/unit" # areas = sub-folders with tests (test_*.py / *_
|
|
|
949
949
|
dir = "tests/e2e" # flat folder: map the test_*.py files to areas instead
|
|
950
950
|
areas = { chat = ["test_chat*.py"], review = ["test_review_*.py"] } # unmatched files form the area `shared`
|
|
951
951
|
|
|
952
|
+
[tool.bdt.ci.plan.tiers.browser]
|
|
953
|
+
dir = "e2e/tests" # another runner: `test_files` says what a test file is (default ["test_*.py", "*_test.py"])
|
|
954
|
+
test_files = ["*.spec.ts"] # Playwright: e2e/tests/<area>/*.spec.ts, run per area with `playwright test e2e/tests/<area>`
|
|
955
|
+
|
|
952
956
|
[tool.bdt.ci.plan.paths] # non-test files an area owns: changing them infers that area instead of everything
|
|
953
957
|
infra = ["infra/**"] # built-in default when the repo has an infra/ folder; add e.g. frontend = ["frontend/**"]
|
|
954
958
|
```
|
|
@@ -49,7 +49,9 @@ LEGACY_LABEL_PREFIX = "e2e-"
|
|
|
49
49
|
FULL_LABEL = "test-full"
|
|
50
50
|
NONE_LABEL = "test-none"
|
|
51
51
|
DEFAULT_TIER_DIRS = {"unit": "tests/unit", "e2e": "tests/e2e"}
|
|
52
|
-
|
|
52
|
+
DEFAULT_TEST_FILES = ("test_*.py", "*_test.py")
|
|
53
|
+
GLOB_MODE_TEST_FILE = "test_*.py"
|
|
54
|
+
IGNORED_DIRS = frozenset({"__pycache__", "node_modules"}) # never hold tests, even when a file there looks like one
|
|
53
55
|
UNMATCHED_AREA = "shared"
|
|
54
56
|
LONG_LIVED = frozenset({"dev", "test", "main"})
|
|
55
57
|
PROMOTIONS = frozenset({("dev", "test"), ("test", "main"), ("main", "dev")})
|
|
@@ -63,30 +65,39 @@ class BranchFlowError(Exception):
|
|
|
63
65
|
"""A fix branch for `main` that was not cut from `main`."""
|
|
64
66
|
|
|
65
67
|
|
|
66
|
-
def _is_test_file(name: str) -> bool:
|
|
67
|
-
return any(PurePosixPath(name).match(g) for g in
|
|
68
|
+
def _is_test_file(name: str, test_files: tuple[str, ...] = DEFAULT_TEST_FILES) -> bool:
|
|
69
|
+
return any(PurePosixPath(name).match(g) for g in test_files)
|
|
68
70
|
|
|
69
71
|
|
|
70
|
-
def _has_tests(folder: Path) -> bool:
|
|
72
|
+
def _has_tests(folder: Path, test_files: tuple[str, ...] = DEFAULT_TEST_FILES) -> bool:
|
|
71
73
|
return any(
|
|
72
|
-
p.is_file() and _is_test_file(p.name) and
|
|
73
|
-
for p in folder.rglob("
|
|
74
|
+
p.is_file() and _is_test_file(p.name, test_files) and not IGNORED_DIRS.intersection(p.relative_to(folder).parts)
|
|
75
|
+
for p in folder.rglob("*")
|
|
74
76
|
)
|
|
75
77
|
|
|
76
78
|
|
|
77
79
|
@dataclass(frozen=True)
|
|
78
80
|
class Tier:
|
|
79
|
-
"""One test tier (unit, e2e, ...). Areas are the sub-folders of `dir` that contain tests (
|
|
80
|
-
`*_test.py`; output and helper folders are not areas), or, with a `globs`
|
|
81
|
-
directly in `dir`."""
|
|
81
|
+
"""One test tier (unit, e2e, ...). Areas are the sub-folders of `dir` that contain tests (files matching
|
|
82
|
+
`test_files`, by default `test_*.py` / `*_test.py`; output and helper folders are not areas), or, with a `globs`
|
|
83
|
+
table, groups of the test files directly in `dir`."""
|
|
82
84
|
|
|
83
85
|
name: str
|
|
84
86
|
dir: str
|
|
85
87
|
globs: Mapping[str, tuple[str, ...]] = field(default_factory=dict)
|
|
88
|
+
test_files: tuple[str, ...] | None = None # None: test_*.py / *_test.py (glob mode: test_*.py only, as before)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def _tests(self) -> tuple[str, ...]:
|
|
92
|
+
if self.test_files is not None:
|
|
93
|
+
return self.test_files
|
|
94
|
+
return (GLOB_MODE_TEST_FILE,) if self.globs else DEFAULT_TEST_FILES
|
|
86
95
|
|
|
87
96
|
def _files(self, root: Path) -> list[str]:
|
|
88
97
|
base = root / self.dir
|
|
89
|
-
return sorted(
|
|
98
|
+
return sorted(
|
|
99
|
+
p.relative_to(root).as_posix() for p in base.iterdir() if p.is_file() and _is_test_file(p.name, self._tests)
|
|
100
|
+
)
|
|
90
101
|
|
|
91
102
|
def _owners(self, path: str) -> frozenset[str]:
|
|
92
103
|
name = PurePosixPath(path).name
|
|
@@ -100,7 +111,12 @@ class Tier:
|
|
|
100
111
|
if self.globs:
|
|
101
112
|
return sorted({a for f in self._files(root) for a in self._owners(f)} | set(self.globs))
|
|
102
113
|
return sorted(
|
|
103
|
-
d.name
|
|
114
|
+
d.name
|
|
115
|
+
for d in base.iterdir()
|
|
116
|
+
if d.is_dir()
|
|
117
|
+
and d.name not in IGNORED_DIRS
|
|
118
|
+
and not d.name.startswith(("_", "."))
|
|
119
|
+
and _has_tests(d, self._tests)
|
|
104
120
|
)
|
|
105
121
|
|
|
106
122
|
def area_of(self, root: Path, path: str, areas: Collection[str]) -> frozenset[str] | None:
|
|
@@ -114,10 +130,10 @@ class Tier:
|
|
|
114
130
|
return None
|
|
115
131
|
parts = pure.relative_to(self.dir).parts
|
|
116
132
|
if self.globs:
|
|
117
|
-
return self._owners(path) if len(parts) == 1 and pure.
|
|
133
|
+
return self._owners(path) if len(parts) == 1 and _is_test_file(pure.name, self._tests) else None
|
|
118
134
|
if len(parts) < 2 or parts[0].startswith(("_", ".")):
|
|
119
135
|
return None
|
|
120
|
-
removed = not (root / self.dir / parts[0]).exists() and _is_test_file(pure.name)
|
|
136
|
+
removed = not (root / self.dir / parts[0]).exists() and _is_test_file(pure.name, self._tests)
|
|
121
137
|
return frozenset({parts[0]}) if parts[0] in areas or removed else None
|
|
122
138
|
|
|
123
139
|
def paths(self, root: Path, selected: Collection[str] | None) -> list[str]:
|
|
@@ -159,6 +175,15 @@ def _strings(value: object, where: str) -> tuple[str, ...]:
|
|
|
159
175
|
return items
|
|
160
176
|
|
|
161
177
|
|
|
178
|
+
def _test_files(name: str, value: object) -> tuple[str, ...]:
|
|
179
|
+
patterns = _strings(value, f"tiers.{name}.test_files")
|
|
180
|
+
if not patterns or any("/" in g for g in patterns):
|
|
181
|
+
raise ValueError(
|
|
182
|
+
f"[tool.bdt.ci.plan.tiers.{name}] test_files must be a non-empty list of file name globs (no folders)"
|
|
183
|
+
)
|
|
184
|
+
return patterns
|
|
185
|
+
|
|
186
|
+
|
|
162
187
|
def _tier(name: str, raw: object) -> Tier:
|
|
163
188
|
table = raw if isinstance(raw, dict) else {}
|
|
164
189
|
directory = table.get("dir", DEFAULT_TIER_DIRS.get(name))
|
|
@@ -168,7 +193,8 @@ def _tier(name: str, raw: object) -> Tier:
|
|
|
168
193
|
if not isinstance(areas, dict):
|
|
169
194
|
raise ValueError(f"[tool.bdt.ci.plan.tiers.{name}] areas must be a table of glob lists")
|
|
170
195
|
globs = {str(area): _strings(g, f"tiers.{name}.areas.{area}") for area, g in areas.items()}
|
|
171
|
-
|
|
196
|
+
test_files = _test_files(name, table["test_files"]) if "test_files" in table else None
|
|
197
|
+
return Tier(name, directory.strip("/"), globs, test_files)
|
|
172
198
|
|
|
173
199
|
|
|
174
200
|
def load_plan_config(start: Path | None = None) -> PlanConfig | None:
|
|
@@ -10,7 +10,7 @@ hooks = [
|
|
|
10
10
|
|
|
11
11
|
[[repos]]
|
|
12
12
|
repo = "https://github.com/astral-sh/ruff-pre-commit"
|
|
13
|
-
rev = "v0.17.
|
|
13
|
+
rev = "v0.17.4" # keep equal to the ruff version in uv.lock
|
|
14
14
|
hooks = [
|
|
15
15
|
{ id = "ruff-check", args = ["--fix"] },
|
|
16
16
|
{ id = "ruff-format" },
|
|
@@ -23,9 +23,9 @@ hooks = [
|
|
|
23
23
|
{ id = "ruff-warn-any", name = "ruff warn: typing.Any (ANN401)", language = "system", entry = "uv run ruff check --select ANN401 --exit-zero --output-format concise", types = ["python"], verbose = true },
|
|
24
24
|
]
|
|
25
25
|
|
|
26
|
-
#
|
|
26
|
+
# repo-wide (tests included); the extras are needed to resolve duckdb/plotly for `bdt usage`
|
|
27
27
|
[[repos]]
|
|
28
28
|
repo = "local"
|
|
29
29
|
hooks = [
|
|
30
|
-
{ id = "ty", name = "ty check", language = "system", entry = "uv run ty check
|
|
30
|
+
{ id = "ty", name = "ty check", language = "system", entry = "uv run --all-extras --all-groups ty check", types = ["python"], pass_filenames = false },
|
|
31
31
|
]
|
|
@@ -10,7 +10,7 @@ packages = ["bmsdna"]
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "bmsdna-devtools"
|
|
13
|
-
version = "1.
|
|
13
|
+
version = "1.2.0"
|
|
14
14
|
description = "Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects"
|
|
15
15
|
readme = "README.md"
|
|
16
16
|
requires-python = ">=3.14" # pgdevkit>=0.7.1 requires 3.14; was >=3.11 before adding it as a dependency
|
|
@@ -25,7 +25,7 @@ dependencies = [
|
|
|
25
25
|
# (schema-apply machinery), which needs psycopg-pool/pydantic -- plain
|
|
26
26
|
# `pgdevkit` alone fails to import pgdevkit.testdb. Possibly worth reporting
|
|
27
27
|
# upstream, but harmless to depend on here either way.
|
|
28
|
-
"pgdevkit[db]>=0.
|
|
28
|
+
"pgdevkit[db]>=0.19.0",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
# `sqlglot` is already a transitive dependency of pgdevkit today, but `bdt lint`'s SQL rules
|
|
@@ -45,8 +45,8 @@ bdt = "bmsdna.devtools.cli:app"
|
|
|
45
45
|
|
|
46
46
|
[dependency-groups]
|
|
47
47
|
dev = [
|
|
48
|
-
"ty>=0.0.
|
|
49
|
-
"ruff>=0.
|
|
48
|
+
"ty>=0.0.100",
|
|
49
|
+
"ruff>=0.17.4",
|
|
50
50
|
]
|
|
51
51
|
test = [
|
|
52
52
|
"pytest>=9.1.0",
|
|
@@ -112,3 +112,7 @@ ban-relative-imports = "all"
|
|
|
112
112
|
|
|
113
113
|
[tool.ty.src]
|
|
114
114
|
exclude = [".worktrees", ".claude"]
|
|
115
|
+
|
|
116
|
+
[tool.uv]
|
|
117
|
+
exclude-newer = "5 days"
|
|
118
|
+
exclude-newer-package = { pgdevkit = false }
|
|
@@ -6,6 +6,10 @@ from __future__ import annotations
|
|
|
6
6
|
from collections.abc import Callable
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
+
import requests
|
|
10
|
+
|
|
11
|
+
from bmsdna.devtools.github_api import GitHubClient
|
|
12
|
+
|
|
9
13
|
NOT_FOUND = object()
|
|
10
14
|
|
|
11
15
|
|
|
@@ -16,24 +20,22 @@ class NotFound:
|
|
|
16
20
|
self.message = message
|
|
17
21
|
|
|
18
22
|
|
|
19
|
-
class FakeResponse:
|
|
23
|
+
class FakeResponse(requests.Response):
|
|
20
24
|
def __init__(self, status_code: int, data: Any) -> None:
|
|
25
|
+
super().__init__()
|
|
21
26
|
self.status_code = status_code
|
|
22
27
|
self._data = data
|
|
23
|
-
self.
|
|
28
|
+
self._content = b"" if data is None else b"x"
|
|
24
29
|
|
|
25
|
-
def json(self) -> Any:
|
|
30
|
+
def json(self, **kwargs: Any) -> Any:
|
|
26
31
|
return self._data
|
|
27
32
|
|
|
28
33
|
|
|
29
|
-
class FakeGitHub:
|
|
30
|
-
owner = "owner"
|
|
31
|
-
repo = "repo"
|
|
32
|
-
repo_path = "repos/owner/repo"
|
|
33
|
-
|
|
34
|
+
class FakeGitHub(GitHubClient):
|
|
34
35
|
def __init__(
|
|
35
36
|
self, routes: dict[str, Any] | None = None, graphql: Callable[[str, dict], dict] | None = None
|
|
36
37
|
) -> None:
|
|
38
|
+
super().__init__("fake-token", "owner", "repo")
|
|
37
39
|
self.routes = routes or {}
|
|
38
40
|
self.graphql_handler = graphql
|
|
39
41
|
self.calls: list[tuple[str, str, Any]] = []
|
|
@@ -43,7 +45,9 @@ class FakeGitHub:
|
|
|
43
45
|
value = self.routes.get(f"{method} {path}")
|
|
44
46
|
return value(payload) if callable(value) else value
|
|
45
47
|
|
|
46
|
-
def request(
|
|
48
|
+
def request(
|
|
49
|
+
self, method: str, path: str, *, ok: tuple[int, ...] = (), retry: bool | None = None, **kwargs: Any
|
|
50
|
+
) -> requests.Response:
|
|
47
51
|
value = self._answer(method, path, kwargs.get("json", kwargs.get("params")))
|
|
48
52
|
if value is NOT_FOUND or isinstance(value, NotFound):
|
|
49
53
|
if 404 not in ok:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dataclasses
|
|
1
2
|
import json
|
|
2
3
|
import textwrap
|
|
3
4
|
import time
|
|
@@ -510,7 +511,7 @@ def test_baseline_stale_reason(tmp_path: Path, change: str, reason: str) -> None
|
|
|
510
511
|
if change == "called":
|
|
511
512
|
_write(tmp_path, "fe/src/b.ts", "fetch('/api/dead');\n")
|
|
512
513
|
else:
|
|
513
|
-
config =
|
|
514
|
+
config = dataclasses.replace(config, exclude_tags=["t"])
|
|
514
515
|
findings = au.check_app(config, repo_root=tmp_path)
|
|
515
516
|
assert [f.rule for f in findings] == ["api-route-baseline-stale"]
|
|
516
517
|
assert reason in findings[0].message
|
|
@@ -535,3 +535,80 @@ def test_path_area_named_like_a_control_label_is_rejected(tmp_path) -> None:
|
|
|
535
535
|
(tmp_path / "pyproject.toml").write_text('[tool.bdt.ci.plan]\n[tool.bdt.ci.plan.paths]\nnone = ["x/**"]\n')
|
|
536
536
|
with pytest.raises(ValueError, match="collide"):
|
|
537
537
|
load_plan_config(tmp_path)
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
# --- tiers.<name>.test_files: non-Python test runners ---------------------------------------
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def _spec_repo(tmp_path):
|
|
544
|
+
touch(
|
|
545
|
+
tmp_path,
|
|
546
|
+
"e2e/tests/assignment/list.spec.ts",
|
|
547
|
+
"e2e/tests/assignment/mask.spec.ts",
|
|
548
|
+
"e2e/tests/cover/cover.spec.ts",
|
|
549
|
+
"e2e/tests/helpers/util.ts",
|
|
550
|
+
"e2e/tests/node_modules/pkg/x.spec.ts",
|
|
551
|
+
"e2e/tests/smoke.spec.ts",
|
|
552
|
+
)
|
|
553
|
+
(tmp_path / "pyproject.toml").write_text(
|
|
554
|
+
'[tool.bdt.ci.plan.tiers.e2e]\ndir = "e2e/tests"\ntest_files = ["*.spec.ts"]\n'
|
|
555
|
+
)
|
|
556
|
+
config = load_plan_config(tmp_path)
|
|
557
|
+
assert config is not None
|
|
558
|
+
return config.tiers[0]
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def test_test_files_make_spec_folders_areas(tmp_path) -> None:
|
|
562
|
+
tier = _spec_repo(tmp_path)
|
|
563
|
+
assert tier.areas(tmp_path) == ["assignment", "cover"]
|
|
564
|
+
assert tier.paths(tmp_path, {"cover"}) == ["e2e/tests/cover"]
|
|
565
|
+
assert tier.paths(tmp_path, None) == ["e2e/tests"]
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
def test_test_files_area_of(tmp_path) -> None:
|
|
569
|
+
tier = _spec_repo(tmp_path)
|
|
570
|
+
assert area_of(tier, tmp_path, "e2e/tests/assignment/list.spec.ts") == {"assignment"}
|
|
571
|
+
assert area_of(tier, tmp_path, "e2e/tests/removed/gone.spec.ts") == {"removed"}
|
|
572
|
+
assert area_of(tier, tmp_path, "e2e/tests/removed/gone.ts") is None
|
|
573
|
+
assert area_of(tier, tmp_path, "e2e/tests/helpers/util.ts") is None
|
|
574
|
+
assert area_of(tier, tmp_path, "e2e/tests/smoke.spec.ts") is None
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
def test_default_test_files_ignore_spec_files(tmp_path) -> None:
|
|
578
|
+
touch(tmp_path, "e2e/tests/assignment/list.spec.ts")
|
|
579
|
+
assert Tier("e2e", "e2e/tests").areas(tmp_path) == []
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def test_test_files_in_glob_mode(tmp_path) -> None:
|
|
583
|
+
touch(tmp_path, "e2e/tests/cover.spec.ts", "e2e/tests/map.spec.ts", "e2e/tests/test_x.py")
|
|
584
|
+
tier = Tier("e2e", "e2e/tests", {"cover": ("cover*",)}, ("*.spec.ts",))
|
|
585
|
+
assert tier.areas(tmp_path) == ["cover", "shared"]
|
|
586
|
+
assert tier.paths(tmp_path, {"shared"}) == ["e2e/tests/map.spec.ts"]
|
|
587
|
+
assert area_of(tier, tmp_path, "e2e/tests/cover.spec.ts") == {"cover"}
|
|
588
|
+
assert area_of(tier, tmp_path, "e2e/tests/test_x.py") is None
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
@pytest.mark.parametrize("value", ["[]", '"*.spec.ts"', "[1]"])
|
|
592
|
+
def test_invalid_test_files_are_rejected(tmp_path, value: str) -> None:
|
|
593
|
+
(tmp_path / "pyproject.toml").write_text(f'[tool.bdt.ci.plan.tiers.e2e]\ndir = "e2e"\ntest_files = {value}\n')
|
|
594
|
+
with pytest.raises(ValueError, match="test_files"):
|
|
595
|
+
load_plan_config(tmp_path)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def test_glob_mode_without_test_files_keeps_matching_only_test_prefix(tmp_path) -> None:
|
|
599
|
+
touch(tmp_path, "tests/e2e/test_a.py", "tests/e2e/helpers_test.py")
|
|
600
|
+
tier = Tier("e2e", "tests/e2e", {"chat": ("test_a*",)})
|
|
601
|
+
assert tier.paths(tmp_path, None) == ["tests/e2e/test_a.py"]
|
|
602
|
+
assert area_of(tier, tmp_path, "tests/e2e/helpers_test.py") is None
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
def test_folder_mode_without_test_files_still_finds_suffix_tests(tmp_path) -> None:
|
|
606
|
+
touch(tmp_path, "tests/unit/billing/orders_test.py")
|
|
607
|
+
assert Tier("unit", "tests/unit").areas(tmp_path) == ["billing"]
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
@pytest.mark.parametrize("value", ['["**/*.spec.ts"]', '["sub/*.spec.ts"]'])
|
|
611
|
+
def test_test_files_with_folders_are_rejected(tmp_path, value: str) -> None:
|
|
612
|
+
(tmp_path / "pyproject.toml").write_text(f'[tool.bdt.ci.plan.tiers.e2e]\ndir = "e2e"\ntest_files = {value}\n')
|
|
613
|
+
with pytest.raises(ValueError, match="no folders"):
|
|
614
|
+
load_plan_config(tmp_path)
|
|
@@ -38,22 +38,26 @@ class FakeResponse:
|
|
|
38
38
|
return self.payload
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
def api(monkeypatch):
|
|
41
|
+
class _Api:
|
|
43
42
|
"""Records requests; `api.routes[url-suffix] = FakeResponse`."""
|
|
44
|
-
calls: list[tuple[str, tuple]] = []
|
|
45
|
-
routes: dict[str, FakeResponse] = {}
|
|
46
43
|
|
|
47
|
-
def
|
|
48
|
-
calls
|
|
49
|
-
|
|
44
|
+
def __init__(self) -> None:
|
|
45
|
+
self.calls: list[tuple[str, tuple | None]] = []
|
|
46
|
+
self.routes: dict[str, FakeResponse] = {}
|
|
47
|
+
|
|
48
|
+
def __call__(self, url: str, auth: tuple | None = None, timeout: float | None = None) -> FakeResponse:
|
|
49
|
+
self.calls.append((url, auth))
|
|
50
|
+
for suffix, response in self.routes.items():
|
|
50
51
|
if url.split("?")[0].endswith(suffix):
|
|
51
52
|
return response
|
|
52
53
|
raise requests.ConnectionError("no route")
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
|
|
56
|
+
@pytest.fixture
|
|
57
|
+
def api(monkeypatch: pytest.MonkeyPatch) -> _Api:
|
|
58
|
+
recorder = _Api()
|
|
59
|
+
monkeypatch.setattr(ci_plan_env.requests, "get", recorder)
|
|
60
|
+
return recorder
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
# --- labels and context ------------------------------------------------------------------------------------------
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from datetime import datetime
|
|
1
2
|
from typing import Any
|
|
2
3
|
|
|
3
4
|
import pytest
|
|
@@ -19,21 +20,28 @@ class FakeResponse:
|
|
|
19
20
|
return self._payload
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
class FakeSession:
|
|
23
|
+
class FakeSession(requests.Session):
|
|
23
24
|
def __init__(self, responses: list[FakeResponse | Exception]) -> None:
|
|
24
|
-
|
|
25
|
+
super().__init__()
|
|
26
|
+
self.responses = responses
|
|
27
|
+
self.calls: list[tuple[str | bytes, str | bytes, dict[str, Any]]] = []
|
|
25
28
|
|
|
26
|
-
def request(self, method: str, url: str, **kwargs: Any) ->
|
|
29
|
+
def request(self, method: str | bytes, url: str | bytes, *args: Any, **kwargs: Any) -> Any:
|
|
27
30
|
self.calls.append((method, url, kwargs))
|
|
28
31
|
item = self.responses.pop(0)
|
|
29
32
|
if isinstance(item, Exception):
|
|
30
33
|
raise item
|
|
31
34
|
return item
|
|
32
35
|
|
|
33
|
-
def head(self, url: str, **kwargs: Any) ->
|
|
36
|
+
def head(self, url: str | bytes, *args: Any, **kwargs: Any) -> Any:
|
|
34
37
|
return self.request("HEAD", url, **kwargs)
|
|
35
38
|
|
|
36
39
|
|
|
40
|
+
def _day(released: datetime | None) -> int:
|
|
41
|
+
assert released is not None
|
|
42
|
+
return released.day
|
|
43
|
+
|
|
44
|
+
|
|
37
45
|
@pytest.fixture(autouse=True)
|
|
38
46
|
def _no_sleep(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
39
47
|
monkeypatch.setattr(osv.time, "sleep", lambda _: None)
|
|
@@ -46,7 +54,7 @@ def test_query_batch_follows_next_page_tokens() -> None:
|
|
|
46
54
|
FakeResponse({"results": [{"vulns": [{"id": "B"}]}]}),
|
|
47
55
|
]
|
|
48
56
|
)
|
|
49
|
-
result = OsvClient(session).query_batch([("PyPI", "x", "1.0"), ("npm", "y", "2.0.0"), ("PyPI", "x", "1.0")])
|
|
57
|
+
result = OsvClient(session).query_batch([("PyPI", "x", "1.0"), ("npm", "y", "2.0.0"), ("PyPI", "x", "1.0")])
|
|
50
58
|
|
|
51
59
|
assert result == {("PyPI", "x", "1.0"): ["A", "B"], ("npm", "y", "2.0.0"): []}
|
|
52
60
|
assert session.calls[1][2]["json"]["queries"] == [
|
|
@@ -56,35 +64,35 @@ def test_query_batch_follows_next_page_tokens() -> None:
|
|
|
56
64
|
|
|
57
65
|
def test_a_short_batch_answer_is_an_error_not_a_clean_result() -> None:
|
|
58
66
|
with pytest.raises(DataError):
|
|
59
|
-
OsvClient(FakeSession([FakeResponse({"results": []})])).query_batch([("PyPI", "x", "1.0")])
|
|
67
|
+
OsvClient(FakeSession([FakeResponse({"results": []})])).query_batch([("PyPI", "x", "1.0")])
|
|
60
68
|
|
|
61
69
|
|
|
62
70
|
def test_transient_failures_are_retried_then_raised() -> None:
|
|
63
71
|
session = FakeSession([FakeResponse(status=503), requests.ConnectionError("boom"), FakeResponse({"id": "A"})])
|
|
64
|
-
assert OsvClient(session).vuln("A") == {"id": "A"}
|
|
72
|
+
assert OsvClient(session).vuln("A") == {"id": "A"}
|
|
65
73
|
|
|
66
74
|
with pytest.raises(DataError):
|
|
67
|
-
OsvClient(FakeSession([FakeResponse(status=503)] * 3)).vuln("A")
|
|
75
|
+
OsvClient(FakeSession([FakeResponse(status=503)] * 3)).vuln("A")
|
|
68
76
|
with pytest.raises(DataError):
|
|
69
|
-
OsvClient(FakeSession([FakeResponse({"id": "other"})])).vuln("A")
|
|
77
|
+
OsvClient(FakeSession([FakeResponse({"id": "other"})])).vuln("A")
|
|
70
78
|
|
|
71
79
|
|
|
72
80
|
def test_kev_is_read_by_cve_id_and_a_bad_feed_is_an_error() -> None:
|
|
73
81
|
assert OsvClient(FakeSession([FakeResponse({"vulnerabilities": [{"cveID": "cve-2026-1"}]})])).kev_cves() == {
|
|
74
82
|
"CVE-2026-1"
|
|
75
|
-
}
|
|
83
|
+
}
|
|
76
84
|
with pytest.raises(DataError):
|
|
77
|
-
OsvClient(FakeSession([FakeResponse({"unexpected": []})])).kev_cves()
|
|
85
|
+
OsvClient(FakeSession([FakeResponse({"unexpected": []})])).kev_cves()
|
|
78
86
|
|
|
79
87
|
|
|
80
88
|
def test_release_time_uses_the_youngest_pypi_file_and_npm_time_map_and_none_for_private_packages() -> None:
|
|
81
89
|
pypi = FakeResponse(
|
|
82
90
|
{"urls": [{"upload_time_iso_8601": "2026-11-01T00:00:00.1Z"}, {"upload_time_iso_8601": "2026-11-03T00:00:00Z"}]}
|
|
83
91
|
)
|
|
84
|
-
assert OsvClient(FakeSession([pypi])).release_time("PyPI", "x", "1.0")
|
|
92
|
+
assert _day(OsvClient(FakeSession([pypi])).release_time("PyPI", "x", "1.0")) == 3
|
|
85
93
|
npm = FakeResponse({"time": {"1.0.0": "2026-11-05T01:00:00.000Z"}})
|
|
86
|
-
assert OsvClient(FakeSession([npm])).release_time("npm", "@s/p", "1.0.0")
|
|
87
|
-
assert OsvClient(FakeSession([FakeResponse(status=404)])).release_time("PyPI", "internal-only", "1.0") is None
|
|
94
|
+
assert _day(OsvClient(FakeSession([npm])).release_time("npm", "@s/p", "1.0.0")) == 5
|
|
95
|
+
assert OsvClient(FakeSession([FakeResponse(status=404)])).release_time("PyPI", "internal-only", "1.0") is None
|
|
88
96
|
|
|
89
97
|
|
|
90
98
|
def test_a_repeating_page_token_is_an_error_not_an_endless_loop() -> None:
|
|
@@ -92,14 +100,14 @@ def test_a_repeating_page_token_is_an_error_not_an_endless_loop() -> None:
|
|
|
92
100
|
session = FakeSession([FakeResponse(page), FakeResponse(page), FakeResponse(page)])
|
|
93
101
|
|
|
94
102
|
with pytest.raises(DataError, match="does not terminate"):
|
|
95
|
-
OsvClient(session).query_batch([("PyPI", "x", "1.0")])
|
|
103
|
+
OsvClient(session).query_batch([("PyPI", "x", "1.0")])
|
|
96
104
|
|
|
97
105
|
|
|
98
106
|
def test_maven_release_time_is_the_pom_last_modified_of_the_first_repository_that_has_it() -> None:
|
|
99
107
|
session = FakeSession(
|
|
100
108
|
[FakeResponse(status=404), FakeResponse(headers={"Last-Modified": "Wed, 13 Aug 2025 20:29:43 GMT"})]
|
|
101
109
|
)
|
|
102
|
-
released = OsvClient(session).release_time("Maven", "androidx.core:core-ktx", "1.17.0")
|
|
110
|
+
released = OsvClient(session).release_time("Maven", "androidx.core:core-ktx", "1.17.0")
|
|
103
111
|
|
|
104
112
|
assert released is not None and (released.year, released.month, released.day, released.hour) == (2025, 8, 13, 20)
|
|
105
113
|
assert [call[1] for call in session.calls] == [
|
|
@@ -109,13 +117,13 @@ def test_maven_release_time_is_the_pom_last_modified_of_the_first_repository_tha
|
|
|
109
117
|
|
|
110
118
|
|
|
111
119
|
def test_maven_release_time_is_none_when_no_repository_has_it_and_an_error_when_one_is_down() -> None:
|
|
112
|
-
assert OsvClient(FakeSession([FakeResponse(status=404)] * 3)).release_time("Maven", "internal:lib", "1") is None
|
|
120
|
+
assert OsvClient(FakeSession([FakeResponse(status=404)] * 3)).release_time("Maven", "internal:lib", "1") is None
|
|
113
121
|
with pytest.raises(DataError):
|
|
114
|
-
OsvClient(FakeSession([FakeResponse(status=503)] * 3)).release_time("Maven", "a:b", "1")
|
|
122
|
+
OsvClient(FakeSession([FakeResponse(status=503)] * 3)).release_time("Maven", "a:b", "1")
|
|
115
123
|
with pytest.raises(DataError):
|
|
116
|
-
OsvClient(FakeSession([FakeResponse(headers={"Last-Modified": "garbage"})])).release_time("Maven", "a:b", "1")
|
|
124
|
+
OsvClient(FakeSession([FakeResponse(headers={"Last-Modified": "garbage"})])).release_time("Maven", "a:b", "1")
|
|
117
125
|
|
|
118
126
|
|
|
119
127
|
def test_a_maven_pom_without_last_modified_is_an_error_not_an_unknown_age() -> None:
|
|
120
128
|
with pytest.raises(DataError, match="Last-Modified"):
|
|
121
|
-
OsvClient(FakeSession([FakeResponse(headers={})])).release_time("Maven", "a:b", "1")
|
|
129
|
+
OsvClient(FakeSession([FakeResponse(headers={})])).release_time("Maven", "a:b", "1")
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
3
|
from bmsdna.devtools.deps.versions import (
|
|
4
|
+
Ecosystem,
|
|
4
5
|
VersionError,
|
|
5
6
|
normalize_name,
|
|
6
7
|
npm_range_satisfied,
|
|
@@ -33,8 +34,8 @@ def test_pypi_names_are_normalised_npm_names_are_not() -> None:
|
|
|
33
34
|
("Maven", "<1.10", "1.10.0", False),
|
|
34
35
|
],
|
|
35
36
|
)
|
|
36
|
-
def test_spec_matches(ecosystem:
|
|
37
|
-
assert spec_matches(ecosystem, spec, version) is expected
|
|
37
|
+
def test_spec_matches(ecosystem: Ecosystem, spec: str, version: str, expected: bool) -> None:
|
|
38
|
+
assert spec_matches(ecosystem, spec, version) is expected
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
def test_semver_prerelease_ordering() -> None:
|