vantage-cli 0.1.4__tar.gz → 0.1.5__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.
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/.github/workflows/ci.yml +1 -1
- vantage_cli-0.1.5/.github/workflows/pages.yml +58 -0
- vantage_cli-0.1.5/.gitignore +66 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/PKG-INFO +1 -1
- vantage_cli-0.1.5/debug_annotations.py +38 -0
- vantage_cli-0.1.5/debug_decorators.py +46 -0
- vantage_cli-0.1.5/debug_typer.py +41 -0
- vantage_cli-0.1.5/debug_wraps.py +57 -0
- vantage_cli-0.1.5/fix_cluster_tests.py +57 -0
- vantage_cli-0.1.5/fix_config_tests.py +51 -0
- vantage_cli-0.1.5/fix_federation_tests.py +47 -0
- vantage_cli-0.1.5/fix_profile_crud.py +86 -0
- vantage_cli-0.1.5/fix_profile_crud_extra.py +110 -0
- vantage_cli-0.1.5/fix_profile_tests.py +48 -0
- vantage_cli-0.1.5/fix_tests.py +68 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/pyproject.toml +17 -1
- vantage_cli-0.1.5/scripts/README.md +166 -0
- vantage_cli-0.1.5/scripts/generate_complete_docs.py +504 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/uv.lock +92 -47
- vantage_cli-0.1.5/vantage_cli/__init__.py +261 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/__init__.py +3 -3
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_juju_localhost/app.py +2 -2
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_microk8s_localhost/app.py +1 -1
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_multipass_localhost/app.py +2 -2
- vantage_cli-0.1.5/vantage_cli/command_decorators.py +110 -0
- vantage_cli-0.1.5/vantage_cli/command_utils.py +45 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/__init__.py +19 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/apps.py +14 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/clouds.py +25 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/clusters.py +14 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/federations.py +14 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/networks.py +14 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/notebooks.py +15 -0
- vantage_cli-0.1.5/vantage_cli/commands/alias/teams.py +15 -0
- {vantage_cli-0.1.4/vantage_cli/commands/apps → vantage_cli-0.1.5/vantage_cli/commands/app}/__init__.py +3 -0
- {vantage_cli-0.1.4/vantage_cli/commands/apps → vantage_cli-0.1.5/vantage_cli/commands/app}/deploy.py +1 -1
- {vantage_cli-0.1.4/vantage_cli/commands/apps → vantage_cli-0.1.5/vantage_cli/commands/app}/list.py +4 -6
- {vantage_cli-0.1.4/vantage_cli/commands/clouds → vantage_cli-0.1.5/vantage_cli/commands/cloud}/__init__.py +7 -3
- vantage_cli-0.1.5/vantage_cli/commands/cloud/get.py +54 -0
- vantage_cli-0.1.5/vantage_cli/commands/cloud/list.py +58 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/__init__.py +5 -1
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/delete.py +3 -2
- vantage_cli-0.1.5/vantage_cli/commands/cluster/federation/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/cluster/federation/create.py +45 -0
- vantage_cli-0.1.5/vantage_cli/commands/cluster/federation/delete.py +55 -0
- vantage_cli-0.1.5/vantage_cli/commands/cluster/federation/get.py +41 -0
- vantage_cli-0.1.5/vantage_cli/commands/cluster/federation/list.py +37 -0
- vantage_cli-0.1.5/vantage_cli/commands/cluster/federation/update.py +61 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/get.py +5 -3
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/list.py +3 -3
- vantage_cli-0.1.5/vantage_cli/commands/config/__init__.py +22 -0
- vantage_cli-0.1.5/vantage_cli/commands/config/clear.py +58 -0
- vantage_cli-0.1.5/vantage_cli/commands/example.py +71 -0
- vantage_cli-0.1.5/vantage_cli/commands/federation/__init__.py +31 -0
- vantage_cli-0.1.5/vantage_cli/commands/federation/create.py +43 -0
- vantage_cli-0.1.5/vantage_cli/commands/federation/delete.py +53 -0
- vantage_cli-0.1.5/vantage_cli/commands/federation/get.py +39 -0
- vantage_cli-0.1.5/vantage_cli/commands/federation/list.py +35 -0
- vantage_cli-0.1.5/vantage_cli/commands/federation/update.py +59 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/__init__.py +22 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/script/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/script/create.py +45 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/script/delete.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/script/get.py +33 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/script/list.py +28 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/script/update.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/submission/__init__.py +21 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/submission/create.py +21 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/submission/delete.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/submission/get.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/submission/list.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/submission/update.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/template/__init__.py +19 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/template/create.py +21 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/template/delete.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/template/get.py +34 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/template/list.py +38 -0
- vantage_cli-0.1.5/vantage_cli/commands/job/template/update.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/__init__.py +24 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/configuration/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/configuration/create.py +55 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/configuration/delete.py +48 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/configuration/get.py +39 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/configuration/list.py +43 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/configuration/update.py +61 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/deployment/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/deployment/create.py +58 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/deployment/delete.py +41 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/deployment/get.py +52 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/deployment/list.py +87 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/deployment/update.py +75 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/product/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/product/create.py +52 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/product/delete.py +48 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/product/get.py +38 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/product/list.py +43 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/product/update.py +59 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/server/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/server/create.py +52 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/server/delete.py +48 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/server/get.py +37 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/server/list.py +33 -0
- vantage_cli-0.1.5/vantage_cli/commands/license/server/update.py +59 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/__init__.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/attach.py +54 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/create.py +56 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/delete.py +41 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/detach.py +47 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/get.py +53 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/list.py +82 -0
- vantage_cli-0.1.5/vantage_cli/commands/network/update.py +62 -0
- vantage_cli-0.1.5/vantage_cli/commands/notebook/__init__.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/notebook/create.py +123 -0
- vantage_cli-0.1.5/vantage_cli/commands/notebook/delete.py +105 -0
- vantage_cli-0.1.5/vantage_cli/commands/notebook/get.py +114 -0
- vantage_cli-0.1.5/vantage_cli/commands/notebook/list.py +168 -0
- vantage_cli-0.1.5/vantage_cli/commands/notebook/update.py +61 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/commands/profile/crud.py +12 -6
- vantage_cli-0.1.5/vantage_cli/commands/storage/__init__.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/attach.py +51 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/create.py +59 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/delete.py +41 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/detach.py +43 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/get.py +56 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/list.py +95 -0
- vantage_cli-0.1.5/vantage_cli/commands/storage/update.py +66 -0
- vantage_cli-0.1.5/vantage_cli/commands/support_ticket/__init__.py +21 -0
- vantage_cli-0.1.5/vantage_cli/commands/support_ticket/create.py +21 -0
- vantage_cli-0.1.5/vantage_cli/commands/support_ticket/delete.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/support_ticket/get.py +36 -0
- vantage_cli-0.1.5/vantage_cli/commands/support_ticket/list.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/support_ticket/update.py +26 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/__init__.py +27 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/add_member.py +27 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/create.py +21 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/delete.py +25 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/get.py +27 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/list.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/list_members.py +35 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/remove_member.py +27 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/set_role.py +30 -0
- vantage_cli-0.1.5/vantage_cli/commands/team/update.py +25 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/config.py +30 -8
- vantage_cli-0.1.5/vantage_cli/decorators.py +90 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/main.py +59 -24
- vantage_cli-0.1.5/vantage_cli/simple_commands.py +77 -0
- vantage_cli-0.1.4/.github/workflows/pages.yml +0 -73
- vantage_cli-0.1.4/.gitignore +0 -30
- vantage_cli-0.1.4/scripts/README.md +0 -55
- vantage_cli-0.1.4/vantage_cli/__init__.py +0 -131
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/.commitlintrc.yml +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/.github/workflows/publish.yml +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/README.md +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/scripts/update_docs_version.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/scripts/update_docs_version.sh +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/common.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_juju_localhost/__init__.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_juju_localhost/bundle_yaml.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_microk8s_localhost/README.md +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_microk8s_localhost/__init__.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/slurm_multipass_localhost/__init__.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/apps/templates.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/auth.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/cache.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/client.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/command_base.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/commands/__init__.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clouds → vantage_cli-0.1.5/vantage_cli/commands/cloud}/add.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clouds → vantage_cli-0.1.5/vantage_cli/commands/cloud}/delete.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clouds → vantage_cli-0.1.5/vantage_cli/commands/cloud}/render.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clouds → vantage_cli-0.1.5/vantage_cli/commands/cloud}/update.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/create.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/render.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/schema.py +0 -0
- {vantage_cli-0.1.4/vantage_cli/commands/clusters → vantage_cli-0.1.5/vantage_cli/commands/cluster}/utils.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/commands/profile/__init__.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/commands/profile/render.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/constants.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/exceptions.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/format.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/gql_client.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/render.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/schemas.py +0 -0
- {vantage_cli-0.1.4 → vantage_cli-0.1.5}/vantage_cli/time_loop.py +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Deploy Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: "pages"
|
|
11
|
+
cancel-in-progress: false
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pages: write
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
name: Build Docusaurus
|
|
21
|
+
runs-on: ubuntu-24.04
|
|
22
|
+
|
|
23
|
+
# Deploy to the github-pages environment
|
|
24
|
+
environment:
|
|
25
|
+
name: github-pages
|
|
26
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
- uses: actions/setup-node@v4
|
|
33
|
+
with:
|
|
34
|
+
node-version: 22
|
|
35
|
+
cache: yarn
|
|
36
|
+
cache-dependency-path: docs/yarn.lock
|
|
37
|
+
|
|
38
|
+
- name: Install just
|
|
39
|
+
run: sudo snap install just --classic
|
|
40
|
+
|
|
41
|
+
- name: Install UV
|
|
42
|
+
run: sudo snap install astral-uv --classic
|
|
43
|
+
|
|
44
|
+
- name: Build website
|
|
45
|
+
run: just docs-build
|
|
46
|
+
|
|
47
|
+
- name: Setup Pages
|
|
48
|
+
uses: actions/configure-pages@v5
|
|
49
|
+
|
|
50
|
+
- name: Upload artifact
|
|
51
|
+
uses: actions/upload-pages-artifact@v3
|
|
52
|
+
with:
|
|
53
|
+
# Upload entire repository
|
|
54
|
+
path: './docs/build'
|
|
55
|
+
|
|
56
|
+
- name: Deploy to GitHub Pages
|
|
57
|
+
id: deployment
|
|
58
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
**/__pycache__/
|
|
3
|
+
**/**/__pycache__/
|
|
4
|
+
|
|
5
|
+
# Docusaurus
|
|
6
|
+
docs/node_modules
|
|
7
|
+
docs/yarn-global
|
|
8
|
+
docs/yarn-cache
|
|
9
|
+
docs/.docusaurus
|
|
10
|
+
docs/build
|
|
11
|
+
docs/.yarn
|
|
12
|
+
docs/yarn-error.log
|
|
13
|
+
docs/npm-debug.log*
|
|
14
|
+
docs/yarn-debug.log*
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Python virtual environments
|
|
18
|
+
.venv
|
|
19
|
+
venv/
|
|
20
|
+
env/
|
|
21
|
+
.env
|
|
22
|
+
**/.env
|
|
23
|
+
|
|
24
|
+
# Coverage reports
|
|
25
|
+
.coverage
|
|
26
|
+
cover_unit
|
|
27
|
+
cover_integration
|
|
28
|
+
cover_combined
|
|
29
|
+
.coverage.*
|
|
30
|
+
coverage
|
|
31
|
+
cover/
|
|
32
|
+
htmlcov/
|
|
33
|
+
|
|
34
|
+
# Testing and linting
|
|
35
|
+
.tox/
|
|
36
|
+
.nox/
|
|
37
|
+
.pytest_cache/
|
|
38
|
+
.pytest_cache/**
|
|
39
|
+
.pytest_cache/**/*
|
|
40
|
+
.pytest_cache/**/*
|
|
41
|
+
.ruff_cache/
|
|
42
|
+
.mypy_cache/
|
|
43
|
+
.dmypy.json
|
|
44
|
+
.dmypy.json/**
|
|
45
|
+
.pyre/
|
|
46
|
+
.pyre/**
|
|
47
|
+
.pyre/**/*
|
|
48
|
+
|
|
49
|
+
# Jupyter
|
|
50
|
+
.ipynb_checkpoints
|
|
51
|
+
|
|
52
|
+
# IDE and editor files
|
|
53
|
+
.vscode/
|
|
54
|
+
.idea/
|
|
55
|
+
*.swp
|
|
56
|
+
*.swo
|
|
57
|
+
*~
|
|
58
|
+
|
|
59
|
+
# OS generated files
|
|
60
|
+
.DS_Store
|
|
61
|
+
.DS_Store?
|
|
62
|
+
._*
|
|
63
|
+
.Spotlight-V100
|
|
64
|
+
.Trashes
|
|
65
|
+
ehthumbs.db
|
|
66
|
+
Thumbs.db
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Debug script to check if JsonOption annotation is the issue."""
|
|
3
|
+
|
|
4
|
+
import inspect
|
|
5
|
+
import typer
|
|
6
|
+
import functools
|
|
7
|
+
from typing_extensions import Annotated
|
|
8
|
+
|
|
9
|
+
JsonOption = Annotated[bool, typer.Option("--json", "-j", help="Output in JSON format")]
|
|
10
|
+
|
|
11
|
+
def test_wrapper1(ctx: typer.Context, json_output: bool = False):
|
|
12
|
+
"""Wrapper with plain bool type."""
|
|
13
|
+
return "test"
|
|
14
|
+
|
|
15
|
+
def test_wrapper2(ctx: typer.Context, json_output: JsonOption = False):
|
|
16
|
+
"""Wrapper with JsonOption type."""
|
|
17
|
+
return "test"
|
|
18
|
+
|
|
19
|
+
print("test_wrapper1 signature (plain bool):")
|
|
20
|
+
print(inspect.signature(test_wrapper1))
|
|
21
|
+
|
|
22
|
+
print("\ntest_wrapper2 signature (JsonOption):")
|
|
23
|
+
print(inspect.signature(test_wrapper2))
|
|
24
|
+
|
|
25
|
+
# Test parameter inspection
|
|
26
|
+
sig1 = inspect.signature(test_wrapper1)
|
|
27
|
+
sig2 = inspect.signature(test_wrapper2)
|
|
28
|
+
|
|
29
|
+
print(f"\ntest_wrapper1 parameters: {list(sig1.parameters.keys())}")
|
|
30
|
+
print(f"test_wrapper2 parameters: {list(sig2.parameters.keys())}")
|
|
31
|
+
|
|
32
|
+
print(f"\njson_output param in wrapper1: {'json_output' in sig1.parameters}")
|
|
33
|
+
print(f"json_output param in wrapper2: {'json_output' in sig2.parameters}")
|
|
34
|
+
|
|
35
|
+
if 'json_output' in sig2.parameters:
|
|
36
|
+
param = sig2.parameters['json_output']
|
|
37
|
+
print(f"json_output annotation: {param.annotation}")
|
|
38
|
+
print(f"json_output default: {param.default}")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Debug script to understand how the decorators work."""
|
|
3
|
+
|
|
4
|
+
import inspect
|
|
5
|
+
import typer
|
|
6
|
+
from vantage_cli.decorators import vantage_command, JsonOption
|
|
7
|
+
|
|
8
|
+
app = typer.Typer()
|
|
9
|
+
|
|
10
|
+
# Test the decorator manually
|
|
11
|
+
def test_func(ctx: typer.Context):
|
|
12
|
+
return "test"
|
|
13
|
+
|
|
14
|
+
print("Original function signature:")
|
|
15
|
+
print(inspect.signature(test_func))
|
|
16
|
+
|
|
17
|
+
# Apply the decorator manually to see what happens
|
|
18
|
+
decorator = vantage_command(app, "test")
|
|
19
|
+
wrapped = decorator(test_func)
|
|
20
|
+
|
|
21
|
+
print("\nAfter applying vantage_command:")
|
|
22
|
+
print(f"wrapped is: {wrapped}")
|
|
23
|
+
print(f"wrapped type: {type(wrapped)}")
|
|
24
|
+
print(f"wrapped signature: {inspect.signature(wrapped)}")
|
|
25
|
+
|
|
26
|
+
print(f"\nRegistered commands: {len(app.registered_commands)}")
|
|
27
|
+
if app.registered_commands:
|
|
28
|
+
cmd = app.registered_commands[0]
|
|
29
|
+
print(f"Command name: {cmd.name}")
|
|
30
|
+
print(f"Command callback: {cmd.callback}")
|
|
31
|
+
print(f"Command callback type: {type(cmd.callback)}")
|
|
32
|
+
if cmd.callback:
|
|
33
|
+
print(f"Command callback signature: {inspect.signature(cmd.callback)}")
|
|
34
|
+
|
|
35
|
+
# Let's also test what the wrapper function looks like in isolation
|
|
36
|
+
import functools
|
|
37
|
+
|
|
38
|
+
def manual_wrapper(func):
|
|
39
|
+
@functools.wraps(func)
|
|
40
|
+
def wrapper(ctx: typer.Context, *args, json_output: JsonOption = False, **kwargs):
|
|
41
|
+
print(f"Wrapper called with json_output={json_output}")
|
|
42
|
+
return func(ctx, *args, **kwargs)
|
|
43
|
+
return wrapper
|
|
44
|
+
|
|
45
|
+
wrapped_manual = manual_wrapper(test_func)
|
|
46
|
+
print(f"\nManual wrapper signature: {inspect.signature(wrapped_manual)}")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Debug script to understand how typer.command works."""
|
|
3
|
+
|
|
4
|
+
import inspect
|
|
5
|
+
import typer
|
|
6
|
+
import functools
|
|
7
|
+
from typing_extensions import Annotated
|
|
8
|
+
|
|
9
|
+
app = typer.Typer()
|
|
10
|
+
|
|
11
|
+
JsonOption = Annotated[bool, typer.Option("--json", "-j", help="Output in JSON format")]
|
|
12
|
+
|
|
13
|
+
def original_func(ctx: typer.Context):
|
|
14
|
+
return "original"
|
|
15
|
+
|
|
16
|
+
print("Original function signature:")
|
|
17
|
+
print(inspect.signature(original_func))
|
|
18
|
+
|
|
19
|
+
# Create a wrapper manually
|
|
20
|
+
@functools.wraps(original_func)
|
|
21
|
+
def wrapper(ctx: typer.Context, *args, json_output: JsonOption = False, **kwargs):
|
|
22
|
+
return original_func(ctx, *args, **kwargs)
|
|
23
|
+
|
|
24
|
+
print(f"\nWrapper signature: {inspect.signature(wrapper)}")
|
|
25
|
+
|
|
26
|
+
# Test what app.command returns
|
|
27
|
+
result = app.command("test")(wrapper)
|
|
28
|
+
|
|
29
|
+
print(f"\napp.command result: {result}")
|
|
30
|
+
print(f"result is wrapper: {result is wrapper}")
|
|
31
|
+
print(f"result is original_func: {result is original_func}")
|
|
32
|
+
print(f"result signature: {inspect.signature(result)}")
|
|
33
|
+
|
|
34
|
+
# Check what's registered
|
|
35
|
+
print(f"\nRegistered commands: {len(app.registered_commands)}")
|
|
36
|
+
if app.registered_commands:
|
|
37
|
+
cmd = app.registered_commands[0]
|
|
38
|
+
print(f"Command callback: {cmd.callback}")
|
|
39
|
+
print(f"Callback is wrapper: {cmd.callback is wrapper}")
|
|
40
|
+
print(f"Callback is result: {cmd.callback is result}")
|
|
41
|
+
print(f"Callback signature: {inspect.signature(cmd.callback)}")
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Debug script to test functools.wraps behavior."""
|
|
3
|
+
|
|
4
|
+
import inspect
|
|
5
|
+
import typer
|
|
6
|
+
import functools
|
|
7
|
+
from typing_extensions import Annotated
|
|
8
|
+
|
|
9
|
+
JsonOption = Annotated[bool, typer.Option("--json", "-j", help="Output in JSON format")]
|
|
10
|
+
|
|
11
|
+
def original_func(ctx: typer.Context):
|
|
12
|
+
"""Original function."""
|
|
13
|
+
return "original"
|
|
14
|
+
|
|
15
|
+
print("Original function signature:")
|
|
16
|
+
print(inspect.signature(original_func))
|
|
17
|
+
|
|
18
|
+
# Test wrapper WITHOUT functools.wraps
|
|
19
|
+
def wrapper_no_wraps(ctx: typer.Context, json_output: JsonOption = False):
|
|
20
|
+
"""Wrapper without functools.wraps."""
|
|
21
|
+
return original_func(ctx)
|
|
22
|
+
|
|
23
|
+
print(f"\nWrapper without @functools.wraps signature:")
|
|
24
|
+
print(inspect.signature(wrapper_no_wraps))
|
|
25
|
+
|
|
26
|
+
# Test wrapper WITH functools.wraps
|
|
27
|
+
@functools.wraps(original_func)
|
|
28
|
+
def wrapper_with_wraps(ctx: typer.Context, json_output: JsonOption = False):
|
|
29
|
+
"""Wrapper with functools.wraps."""
|
|
30
|
+
return original_func(ctx)
|
|
31
|
+
|
|
32
|
+
print(f"\nWrapper with @functools.wraps signature:")
|
|
33
|
+
print(inspect.signature(wrapper_with_wraps))
|
|
34
|
+
|
|
35
|
+
print(f"\nWrapper without wraps parameters: {list(inspect.signature(wrapper_no_wraps).parameters.keys())}")
|
|
36
|
+
print(f"Wrapper with wraps parameters: {list(inspect.signature(wrapper_with_wraps).parameters.keys())}")
|
|
37
|
+
|
|
38
|
+
# Check what __wrapped__ attribute contains
|
|
39
|
+
if hasattr(wrapper_with_wraps, '__wrapped__'):
|
|
40
|
+
print(f"\n__wrapped__ signature: {inspect.signature(wrapper_with_wraps.__wrapped__)}")
|
|
41
|
+
|
|
42
|
+
# Test manually setting signature
|
|
43
|
+
wrapper_manual = lambda ctx, json_output=False: original_func(ctx)
|
|
44
|
+
wrapper_manual.__name__ = original_func.__name__
|
|
45
|
+
wrapper_manual.__doc__ = original_func.__doc__
|
|
46
|
+
|
|
47
|
+
print(f"\nManual wrapper (before signature): {inspect.signature(wrapper_manual)}")
|
|
48
|
+
|
|
49
|
+
# Manually set the signature
|
|
50
|
+
from inspect import Parameter, Signature
|
|
51
|
+
params = [
|
|
52
|
+
Parameter('ctx', Parameter.POSITIONAL_OR_KEYWORD, annotation=typer.Context),
|
|
53
|
+
Parameter('json_output', Parameter.KEYWORD_ONLY, default=False, annotation=JsonOption)
|
|
54
|
+
]
|
|
55
|
+
wrapper_manual.__signature__ = Signature(params)
|
|
56
|
+
|
|
57
|
+
print(f"Manual wrapper (after signature): {inspect.signature(wrapper_manual)}")
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Script to fix cluster tests by applying json_output parameter removal pattern."""
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
def fix_cluster_tests():
|
|
7
|
+
file_path = "tests/unit/test_cluster_commands.py"
|
|
8
|
+
|
|
9
|
+
with open(file_path, 'r') as f:
|
|
10
|
+
content = f.read()
|
|
11
|
+
|
|
12
|
+
# Add SimpleNamespace import if not present
|
|
13
|
+
if "from types import SimpleNamespace" not in content:
|
|
14
|
+
content = content.replace(
|
|
15
|
+
"from unittest.mock import Mock, patch",
|
|
16
|
+
"from types import SimpleNamespace\nfrom unittest.mock import Mock, patch"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Fix mock_context fixtures
|
|
20
|
+
fixture_pattern = r'(ctx\.obj = Mock\(\)\s+ctx\.obj\.settings = Mock\(\)\s+ctx\.obj\.profile = "default")'
|
|
21
|
+
fixture_replacement = 'ctx.obj = SimpleNamespace(\n profile="default",\n verbose=False,\n json_output=False\n )'
|
|
22
|
+
|
|
23
|
+
content = re.sub(fixture_pattern, fixture_replacement, content, flags=re.MULTILINE)
|
|
24
|
+
|
|
25
|
+
# Fix function calls - remove json_output parameters
|
|
26
|
+
patterns_to_fix = [
|
|
27
|
+
(r'list_clusters\(([^,]+), json_output=\w+\)', r'list_clusters(\1)'),
|
|
28
|
+
(r'delete_cluster\(([^,]+), ([^,]+), force=(\w+), json_output=\w+\)', r'delete_cluster(\1, \2, force=\3)'),
|
|
29
|
+
(r'get_cluster\(([^,]+), ([^,]+), json_output=\w+\)', r'get_cluster(\1, \2)'),
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
for pattern, replacement in patterns_to_fix:
|
|
33
|
+
content = re.sub(pattern, replacement, content)
|
|
34
|
+
|
|
35
|
+
# Add context setting before function calls for json_output tests
|
|
36
|
+
content = re.sub(
|
|
37
|
+
r'(mock_get_effective_json_output\.return_value = True)\s+(# Call the function)',
|
|
38
|
+
r'\1\n mock_ctx.obj.json_output = True\n \2',
|
|
39
|
+
content,
|
|
40
|
+
flags=re.MULTILINE
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Handle cases where json_output is False
|
|
44
|
+
content = re.sub(
|
|
45
|
+
r'(await list_clusters\(mock_ctx\))\s+(# Check that render_json was called)',
|
|
46
|
+
r'mock_ctx.obj.json_output = True\n \1\n \2',
|
|
47
|
+
content,
|
|
48
|
+
flags=re.MULTILINE
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
with open(file_path, 'w') as f:
|
|
52
|
+
f.write(content)
|
|
53
|
+
|
|
54
|
+
print("Cluster tests fixed!")
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
fix_cluster_tests()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Script to fix config tests by applying json_output parameter removal pattern."""
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
def fix_config_tests():
|
|
7
|
+
file_path = "tests/unit/test_config_commands.py"
|
|
8
|
+
|
|
9
|
+
with open(file_path, 'r') as f:
|
|
10
|
+
content = f.read()
|
|
11
|
+
|
|
12
|
+
# Add SimpleNamespace import if not present
|
|
13
|
+
if "from types import SimpleNamespace" not in content:
|
|
14
|
+
content = content.replace(
|
|
15
|
+
"from unittest.mock import AsyncMock, Mock, patch",
|
|
16
|
+
"from types import SimpleNamespace\nfrom unittest.mock import AsyncMock, Mock, patch"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Fix mock_context fixtures - replace Mock objects with SimpleNamespace
|
|
20
|
+
fixture_pattern = r'(ctx\.obj = Mock\(\)[^}]+ctx\.obj\.profile = "default"[^}]*return ctx)'
|
|
21
|
+
fixture_replacement = '''ctx.obj = SimpleNamespace(
|
|
22
|
+
profile="default",
|
|
23
|
+
verbose=False,
|
|
24
|
+
json_output=False
|
|
25
|
+
)
|
|
26
|
+
return ctx'''
|
|
27
|
+
|
|
28
|
+
content = re.sub(fixture_pattern, fixture_replacement, content, flags=re.MULTILINE | re.DOTALL)
|
|
29
|
+
|
|
30
|
+
# Fix function calls - remove json_output parameters and add context setting
|
|
31
|
+
patterns_to_fix = [
|
|
32
|
+
(r'(await clear_config\([^,]+), json_output=(\w+)\)', r'mock_ctx.obj.json_output = \2\n \1)'),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
for pattern, replacement in patterns_to_fix:
|
|
36
|
+
content = re.sub(pattern, replacement, content)
|
|
37
|
+
|
|
38
|
+
# Also fix any direct call patterns
|
|
39
|
+
content = re.sub(
|
|
40
|
+
r'await clear_config\(([^,]+), force=(\w+), json_output=(\w+)\)',
|
|
41
|
+
r'mock_ctx.obj.json_output = \3\n await clear_config(\1, force=\2)',
|
|
42
|
+
content
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
with open(file_path, 'w') as f:
|
|
46
|
+
f.write(content)
|
|
47
|
+
|
|
48
|
+
print("Config tests fixed!")
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
fix_config_tests()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Script to fix federation tests by applying json_output parameter removal pattern."""
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
def fix_federation_tests():
|
|
7
|
+
file_path = "tests/unit/test_federation_commands.py"
|
|
8
|
+
|
|
9
|
+
with open(file_path, 'r') as f:
|
|
10
|
+
content = f.read()
|
|
11
|
+
|
|
12
|
+
# Fix mock_context fixtures
|
|
13
|
+
fixture_pattern = r'(ctx\.obj = Mock\(\)\s+ctx\.obj\.settings = Mock\(\)\s+ctx\.obj\.profile = "default")'
|
|
14
|
+
fixture_replacement = 'ctx.obj = SimpleNamespace(\n profile="default",\n verbose=False,\n json_output=False\n )'
|
|
15
|
+
|
|
16
|
+
content = re.sub(fixture_pattern, fixture_replacement, content, flags=re.MULTILINE)
|
|
17
|
+
|
|
18
|
+
# Fix function calls - remove json_output parameters
|
|
19
|
+
patterns_to_fix = [
|
|
20
|
+
(r'list_federations\(([^,]+), json_output=\w+\)', r'list_federations(\1)'),
|
|
21
|
+
(r'create_federation\(([^,]+), ([^,]+), ([^,]+), json_output=\w+\)', r'create_federation(\1, \2, \3)'),
|
|
22
|
+
(r'delete_federation\(([^,]+), ([^,]+), force=(\w+), json_output=\w+\)', r'delete_federation(\1, \2, force=\3)'),
|
|
23
|
+
(r'get_federation\(([^,]+), ([^,]+), json_output=\w+\)', r'get_federation(\1, \2)'),
|
|
24
|
+
(r'update_federation\(([^,]+), ([^,]+), json_output=\w+\)', r'update_federation(\1, \2)'),
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
for pattern, replacement in patterns_to_fix:
|
|
28
|
+
content = re.sub(pattern, replacement, content)
|
|
29
|
+
|
|
30
|
+
# Add context setting before function calls
|
|
31
|
+
json_output_patterns = [
|
|
32
|
+
(r'(mock_get_json_output\.return_value = True)\s+# Run the command\s+import asyncio\s+(asyncio\.run\(list_federations\(mock_context\)\))',
|
|
33
|
+
r'\1\n mock_context.obj.json_output = True\n # Run the command\n import asyncio\n \2'),
|
|
34
|
+
(r'(mock_get_json_output\.return_value = False)\s+mock_console = Mock\(\)\s+mock_console_class\.return_value = mock_console\s+# Run the command\s+import asyncio\s+(asyncio\.run\(list_federations\(mock_context\)\))',
|
|
35
|
+
r'\1\n mock_console = Mock()\n mock_console_class.return_value = mock_console\n mock_context.obj.json_output = False\n # Run the command\n import asyncio\n \2'),
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
for pattern, replacement in json_output_patterns:
|
|
39
|
+
content = re.sub(pattern, replacement, content, flags=re.MULTILINE | re.DOTALL)
|
|
40
|
+
|
|
41
|
+
with open(file_path, 'w') as f:
|
|
42
|
+
f.write(content)
|
|
43
|
+
|
|
44
|
+
print("Federation tests fixed!")
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
fix_federation_tests()
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Fix profile CRUD tests by removing json_output parameters and updating context setup."""
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
def fix_profile_crud_tests():
|
|
7
|
+
# Read the file
|
|
8
|
+
with open('tests/unit/test_profile_crud.py', 'r') as f:
|
|
9
|
+
content = f.read()
|
|
10
|
+
|
|
11
|
+
# Pattern 1: Remove json_output=True/False from function calls
|
|
12
|
+
# create_profile(ctx=mock_ctx, profile_name="test_profile", json_output=True)
|
|
13
|
+
content = re.sub(
|
|
14
|
+
r'(create_profile\([^)]*), json_output=[^)]*\)',
|
|
15
|
+
r'\1)',
|
|
16
|
+
content
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# delete_profile(ctx=mock_ctx, profile_name="nonexistent", json_output=False)
|
|
20
|
+
content = re.sub(
|
|
21
|
+
r'(delete_profile\([^)]*), json_output=[^)]*\)',
|
|
22
|
+
r'\1)',
|
|
23
|
+
content
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# get_profile(ctx=mock_ctx, profile_name="test_profile", json_output=True)
|
|
27
|
+
content = re.sub(
|
|
28
|
+
r'(get_profile\([^)]*), json_output=[^)]*\)',
|
|
29
|
+
r'\1)',
|
|
30
|
+
content
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# list_profiles(ctx=mock_ctx, json_output=True)
|
|
34
|
+
content = re.sub(
|
|
35
|
+
r'(list_profiles\([^)]*), json_output=[^)]*\)',
|
|
36
|
+
r'\1)',
|
|
37
|
+
content
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# use_profile(ctx=mock_ctx, profile_name="test_profile", json_output=True)
|
|
41
|
+
content = re.sub(
|
|
42
|
+
r'(use_profile\([^)]*), json_output=[^)]*\)',
|
|
43
|
+
r'\1)',
|
|
44
|
+
content
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Pattern 2: Handle multiline function calls with json_output
|
|
48
|
+
# For create_profile with multiple parameters including json_output
|
|
49
|
+
content = re.sub(
|
|
50
|
+
r'(create_profile\([\s\S]*?),\s*json_output=[^,)]*\s*\)',
|
|
51
|
+
r'\1)',
|
|
52
|
+
content
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Pattern 3: Update mock_ctx = MagicMock() to include SimpleNamespace setup
|
|
56
|
+
# Look for test methods that don't already have the obj setup
|
|
57
|
+
def update_mock_ctx(match):
|
|
58
|
+
method_content = match.group(0)
|
|
59
|
+
# Check if SimpleNamespace is already set up
|
|
60
|
+
if 'mock_ctx.obj = SimpleNamespace' in method_content:
|
|
61
|
+
return method_content
|
|
62
|
+
|
|
63
|
+
# Find the mock_ctx = MagicMock() line and add the obj setup after it
|
|
64
|
+
method_content = re.sub(
|
|
65
|
+
r'(mock_ctx = MagicMock\(\))',
|
|
66
|
+
r'\1\n mock_ctx.obj = SimpleNamespace(profile="default", verbose=False, json_output=True)',
|
|
67
|
+
method_content
|
|
68
|
+
)
|
|
69
|
+
return method_content
|
|
70
|
+
|
|
71
|
+
# Apply to all test methods
|
|
72
|
+
content = re.sub(
|
|
73
|
+
r'(def test_[^:]*:.*?)(?=def|\Z)',
|
|
74
|
+
update_mock_ctx,
|
|
75
|
+
content,
|
|
76
|
+
flags=re.DOTALL
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Write the file back
|
|
80
|
+
with open('tests/unit/test_profile_crud.py', 'w') as f:
|
|
81
|
+
f.write(content)
|
|
82
|
+
|
|
83
|
+
print("Profile CRUD tests fixed!")
|
|
84
|
+
|
|
85
|
+
if __name__ == '__main__':
|
|
86
|
+
fix_profile_crud_tests()
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Fix profile CRUD extra tests by removing json_output parameters and updating context setup."""
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
def fix_profile_crud_extra_tests():
|
|
7
|
+
# Read the file
|
|
8
|
+
with open('tests/unit/test_profile_crud_extra.py', 'r') as f:
|
|
9
|
+
content = f.read()
|
|
10
|
+
|
|
11
|
+
# Add SimpleNamespace import
|
|
12
|
+
content = re.sub(
|
|
13
|
+
r'(from unittest.mock import MagicMock, patch)',
|
|
14
|
+
r'from types import SimpleNamespace\nfrom unittest.mock import MagicMock, patch',
|
|
15
|
+
content
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Pattern 1: Remove json_output=True/False from function calls
|
|
19
|
+
content = re.sub(
|
|
20
|
+
r'(create_profile\([^)]*), json_output=[^)]*\)',
|
|
21
|
+
r'\1)',
|
|
22
|
+
content
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
content = re.sub(
|
|
26
|
+
r'(delete_profile\([^)]*), json_output=[^)]*\)',
|
|
27
|
+
r'\1)',
|
|
28
|
+
content
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
content = re.sub(
|
|
32
|
+
r'(get_profile\([^)]*), json_output=[^)]*\)',
|
|
33
|
+
r'\1)',
|
|
34
|
+
content
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
content = re.sub(
|
|
38
|
+
r'(list_profiles\([^)]*), json_output=[^)]*\)',
|
|
39
|
+
r'\1)',
|
|
40
|
+
content
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
content = re.sub(
|
|
44
|
+
r'(use_profile\([^)]*), json_output=[^)]*\)',
|
|
45
|
+
r'\1)',
|
|
46
|
+
content
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Pattern 2: Handle multiline function calls with json_output
|
|
50
|
+
content = re.sub(
|
|
51
|
+
r'(create_profile\([\s\S]*?),\s*json_output=[^,)]*\s*\)',
|
|
52
|
+
r'\1)',
|
|
53
|
+
content
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
content = re.sub(
|
|
57
|
+
r'(delete_profile\([\s\S]*?),\s*json_output=[^,)]*\s*\)',
|
|
58
|
+
r'\1)',
|
|
59
|
+
content
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
content = re.sub(
|
|
63
|
+
r'(get_profile\([\s\S]*?),\s*json_output=[^,)]*\s*\)',
|
|
64
|
+
r'\1)',
|
|
65
|
+
content
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
content = re.sub(
|
|
69
|
+
r'(list_profiles\([\s\S]*?),\s*json_output=[^,)]*\s*\)',
|
|
70
|
+
r'\1)',
|
|
71
|
+
content
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
content = re.sub(
|
|
75
|
+
r'(use_profile\([\s\S]*?),\s*json_output=[^,)]*\s*\)',
|
|
76
|
+
r'\1)',
|
|
77
|
+
content
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Pattern 3: Update mock_ctx = MagicMock() to include SimpleNamespace setup
|
|
81
|
+
def update_mock_ctx(match):
|
|
82
|
+
method_content = match.group(0)
|
|
83
|
+
# Check if SimpleNamespace is already set up
|
|
84
|
+
if 'mock_ctx.obj = SimpleNamespace' in method_content:
|
|
85
|
+
return method_content
|
|
86
|
+
|
|
87
|
+
# Find the mock_ctx = MagicMock() line and add the obj setup after it
|
|
88
|
+
method_content = re.sub(
|
|
89
|
+
r'(mock_ctx = MagicMock\(\))',
|
|
90
|
+
r'\1\n mock_ctx.obj = SimpleNamespace(profile="default", verbose=False, json_output=True)',
|
|
91
|
+
method_content
|
|
92
|
+
)
|
|
93
|
+
return method_content
|
|
94
|
+
|
|
95
|
+
# Apply to all test functions
|
|
96
|
+
content = re.sub(
|
|
97
|
+
r'(def test_[^:]*:.*?)(?=def|\Z)',
|
|
98
|
+
update_mock_ctx,
|
|
99
|
+
content,
|
|
100
|
+
flags=re.DOTALL
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# Write the file back
|
|
104
|
+
with open('tests/unit/test_profile_crud_extra.py', 'w') as f:
|
|
105
|
+
f.write(content)
|
|
106
|
+
|
|
107
|
+
print("Profile CRUD extra tests fixed!")
|
|
108
|
+
|
|
109
|
+
if __name__ == '__main__':
|
|
110
|
+
fix_profile_crud_extra_tests()
|