qbraid-cli 0.9.8__tar.gz → 0.9.10__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.
Potentially problematic release.
This version of qbraid-cli might be problematic. Click here for more details.
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/ci-pr-target.yml +1 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/main.yml +1 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/PKG-INFO +1 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/pyproject.toml +1 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/_version.py +2 -2
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/admin/headers.py +1 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/configure/actions.py +3 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/files/app.py +22 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli.egg-info/PKG-INFO +1 -1
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/admin/test_headers.py +6 -2
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/configure/test_configure_validate_input.py +13 -2
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/files/test_files_commands.py +41 -2
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.env.example +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/dependabot.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/bump-version.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/docs-pr.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/docs.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/format.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/pre-release.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/publish.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.github/workflows/tag-on-merge.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.gitignore +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/.readthedocs.yml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/CONTRIBUTING.md +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/LICENSE +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/MANIFEST.IN +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/Makefile +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/README.md +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/Makefile +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/_static/favicon.ico +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/_static/logo.png +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/_static/style/custom.css +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/_static/style/s4defs-roles.css +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/conf.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/index.rst +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/make.bat +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/docs/requirements.txt +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/account/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/account/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/admin/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/admin/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/admin/validation.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/chat/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/chat/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/configure/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/configure/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/devices/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/devices/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/devices/validation.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/envs/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/envs/activate.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/envs/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/envs/create.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/envs/data_handling.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/exceptions.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/files/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/handlers.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/jobs/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/jobs/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/jobs/toggle_braket.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/jobs/validation.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/kernels/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/kernels/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/main.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/pip/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/pip/app.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/pip/hooks.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli/py.typed +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli.egg-info/SOURCES.txt +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli.egg-info/dependency_links.txt +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli.egg-info/entry_points.txt +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli.egg-info/requires.txt +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/qbraid_cli.egg-info/top_level.txt +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/setup.cfg +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/account/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/account/test_account_credits.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/configure/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/configure/test_configure_commands.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/configure/test_configure_prompt_for_config.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/configure/test_configure_set.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/conftest.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/devices/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/devices/test_devices_list.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/devices/test_devices_validations.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_activate.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_activate_find_shell_rc.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_activate_print_command.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_activate_pyenv.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_create_from_yaml.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_list.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/envs/test_envs_remove.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/files/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_disable.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_enable.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_list.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_state.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_toggle_braket_confirm.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_toggle_braket_disable.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_toggle_braket_enable.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_toggle_braket_get_data.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_validate_get_state.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_validate_handle_state.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/jobs/test_jobs_validate_library.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/kernels/__init__.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/kernels/test_kernels_list.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/resources/envs/correct.yaml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/resources/envs/icon.png +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tests/resources/envs/incorrect.yaml +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tools/bump_version.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tools/create_dev_build.sh +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tools/install_wheel_extras.sh +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tools/split_md.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tools/split_rst.py +0 -0
- {qbraid_cli-0.9.8 → qbraid_cli-0.9.10}/tools/stamp_pre_release.py +0 -0
|
@@ -73,7 +73,7 @@ jobs:
|
|
|
73
73
|
QBRAID_API_KEY: ${{ secrets.QBRAID_API_KEY }}
|
|
74
74
|
- name: Upload coverage to Codecov
|
|
75
75
|
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
|
|
76
|
-
uses: codecov/codecov-action@v5.1
|
|
76
|
+
uses: codecov/codecov-action@v5.3.1
|
|
77
77
|
with:
|
|
78
78
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
79
79
|
fail_ci_if_error: false
|
|
@@ -76,7 +76,7 @@ jobs:
|
|
|
76
76
|
QBRAID_API_KEY: ${{ secrets.QBRAID_API_KEY }}
|
|
77
77
|
- name: Upload coverage to Codecov
|
|
78
78
|
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
|
|
79
|
-
uses: codecov/codecov-action@v5.1
|
|
79
|
+
uses: codecov/codecov-action@v5.3.1
|
|
80
80
|
with:
|
|
81
81
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
82
82
|
fail_ci_if_error: false
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qbraid-cli"
|
|
7
|
-
version = "0.9.
|
|
7
|
+
version = "0.9.10"
|
|
8
8
|
description = "Command Line Interface for interacting with all parts of the qBraid platform."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "qBraid Development Team", email = "contact@qbraid.com" }]
|
|
@@ -12,5 +12,5 @@ __version__: str
|
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
|
13
13
|
version_tuple: VERSION_TUPLE
|
|
14
14
|
|
|
15
|
-
__version__ = version = '0.1.dev1+
|
|
16
|
-
__version_tuple__ = version_tuple = (0, 1, 'dev1', '
|
|
15
|
+
__version__ = version = '0.1.dev1+g1c04ca7'
|
|
16
|
+
__version_tuple__ = version_tuple = (0, 1, 'dev1', 'g1c04ca7')
|
|
@@ -170,7 +170,7 @@ def check_and_fix_headers(
|
|
|
170
170
|
failed_headers.append(file_path)
|
|
171
171
|
else:
|
|
172
172
|
# Form the new content by combining the header, one blank line, and the actual content
|
|
173
|
-
new_content = updated_header.strip() + "\n\n" + actual_content
|
|
173
|
+
new_content = updated_header.strip() + "\n\n" + actual_content + "\n"
|
|
174
174
|
with open(file_path, "w", encoding="ISO-8859-1") as f:
|
|
175
175
|
f.write(new_content)
|
|
176
176
|
fixed_headers.append(file_path)
|
|
@@ -37,6 +37,8 @@ def validate_input(key: str, value: str) -> str:
|
|
|
37
37
|
Raises:
|
|
38
38
|
typer.BadParameter: If the value is invalid
|
|
39
39
|
"""
|
|
40
|
+
value = value.strip()
|
|
41
|
+
|
|
40
42
|
if key == "url":
|
|
41
43
|
if not re.match(r"^https?://\S+$", value):
|
|
42
44
|
raise typer.BadParameter("Invalid URL format.")
|
|
@@ -44,7 +46,7 @@ def validate_input(key: str, value: str) -> str:
|
|
|
44
46
|
if not re.match(r"^\S+@\S+\.\S+$", value):
|
|
45
47
|
raise typer.BadParameter("Invalid email format.")
|
|
46
48
|
elif key == "api-key":
|
|
47
|
-
if not
|
|
49
|
+
if not re.match(r"^[a-zA-Z0-9]+$", value):
|
|
48
50
|
raise typer.BadParameter("Invalid API key format.")
|
|
49
51
|
return value
|
|
50
52
|
|
|
@@ -12,11 +12,29 @@ from typing import Any
|
|
|
12
12
|
import rich
|
|
13
13
|
import typer
|
|
14
14
|
|
|
15
|
-
from qbraid_cli.handlers import run_progress_task
|
|
15
|
+
from qbraid_cli.handlers import handle_error, run_progress_task
|
|
16
16
|
|
|
17
17
|
files_app = typer.Typer(help="Manage qBraid cloud storage files.", no_args_is_help=True)
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def is_file_less_than_10mb(file_path: Path) -> bool:
|
|
21
|
+
"""
|
|
22
|
+
Check if the given file is less than 10MB in size.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
file_path (Path): The path to the file to check.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
bool: True if the file is less than 10MB, False otherwise.
|
|
29
|
+
"""
|
|
30
|
+
TEN_MB = 10 * 1024 * 1024 # 10 * 1024 KB * 1024 bytes
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
return file_path.stat().st_size < TEN_MB
|
|
34
|
+
except OSError:
|
|
35
|
+
return False
|
|
36
|
+
|
|
37
|
+
|
|
20
38
|
@files_app.command(name="upload")
|
|
21
39
|
def files_upload(
|
|
22
40
|
filepath: Path = typer.Argument(
|
|
@@ -47,6 +65,9 @@ def files_upload(
|
|
|
47
65
|
):
|
|
48
66
|
"""Upload a local file to qBraid storage."""
|
|
49
67
|
|
|
68
|
+
if not is_file_less_than_10mb(filepath):
|
|
69
|
+
handle_error("Error", "File too large. Must be less than 10MB for direct upload.")
|
|
70
|
+
|
|
50
71
|
def upload_file() -> dict[str, Any]:
|
|
51
72
|
from qbraid_core.services.files import FileManagerClient
|
|
52
73
|
|
|
@@ -42,7 +42,7 @@ def _get_test_file(test_type: str, ext: str = ".py") -> str:
|
|
|
42
42
|
with open(file_path, "w") as f:
|
|
43
43
|
prev_year_header = f"""{comment_marker} Copyright (c) {str(datetime.datetime.now().year - 1)}, qBraid Development Team
|
|
44
44
|
{comment_marker} All rights reserved."""
|
|
45
|
-
f.write(prev_year_header + "\n\n" + "print('hello world')")
|
|
45
|
+
f.write(prev_year_header + "\n\n" + "print('hello world')" + "\n")
|
|
46
46
|
else:
|
|
47
47
|
raise ValueError(f"Invalid test type: {test_type}")
|
|
48
48
|
|
|
@@ -102,7 +102,10 @@ def test_header_fix_for_file_with_no_header(ext):
|
|
|
102
102
|
with open(file_path, "r") as f:
|
|
103
103
|
assert (
|
|
104
104
|
f.read()
|
|
105
|
-
== DEFAULT_HEADER.replace("#", comment_marker)
|
|
105
|
+
== DEFAULT_HEADER.replace("#", comment_marker)
|
|
106
|
+
+ "\n"
|
|
107
|
+
+ "print('hello world')"
|
|
108
|
+
+ "\n"
|
|
106
109
|
)
|
|
107
110
|
finally:
|
|
108
111
|
remove_test_file("no_header", ext)
|
|
@@ -127,6 +130,7 @@ def test_header_update_for_file_with_old_header(ext):
|
|
|
127
130
|
== get_formatted_header(HeaderType.gpl, "test_project").replace("#", comment_marker)
|
|
128
131
|
+ "\n"
|
|
129
132
|
+ "print('hello world')"
|
|
133
|
+
+ "\n"
|
|
130
134
|
)
|
|
131
135
|
finally:
|
|
132
136
|
remove_test_file("old_header", ext)
|
|
@@ -26,6 +26,17 @@ def test_validate_input_valid(key, value):
|
|
|
26
26
|
assert validate_input(key, value) == value, f"Valid {key} should not raise an exception"
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
@pytest.mark.parametrize(
|
|
30
|
+
"key,value,expected",
|
|
31
|
+
[
|
|
32
|
+
("api-key", "a1B2c3D4e5F\r", "a1B2c3D4e5F"),
|
|
33
|
+
],
|
|
34
|
+
)
|
|
35
|
+
def test_validate_input_valid_strip(key, value, expected):
|
|
36
|
+
"""Test validate_input with valid inputs."""
|
|
37
|
+
assert validate_input(key, value) == expected, f"Valid {key} should not raise an exception"
|
|
38
|
+
|
|
39
|
+
|
|
29
40
|
@pytest.mark.parametrize(
|
|
30
41
|
"key,value,exception_message",
|
|
31
42
|
[
|
|
@@ -33,8 +44,8 @@ def test_validate_input_valid(key, value):
|
|
|
33
44
|
("url", "example.com", "Invalid URL format."),
|
|
34
45
|
("email", "user@example", "Invalid email format."),
|
|
35
46
|
("email", "userexample.com", "Invalid email format."),
|
|
36
|
-
("api-key", "1234567890", "Invalid API key format."),
|
|
37
|
-
("api-key", "a1B2c3D4e5F6g", "Invalid API key format."),
|
|
47
|
+
("api-key", "@#$1234567890", "Invalid API key format."),
|
|
48
|
+
("api-key", "a1B2c3D4e5F6g^74()", "Invalid API key format."),
|
|
38
49
|
],
|
|
39
50
|
)
|
|
40
51
|
def test_validate_input_invalid(key, value, exception_message):
|
|
@@ -8,12 +8,13 @@ Unit tests for the `qbraid_cli.files.app` module.
|
|
|
8
8
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
from
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from unittest.mock import Mock, patch
|
|
12
13
|
|
|
13
14
|
import pytest
|
|
14
15
|
from typer.testing import CliRunner
|
|
15
16
|
|
|
16
|
-
from qbraid_cli.files.app import files_app
|
|
17
|
+
from qbraid_cli.files.app import files_app, is_file_less_than_10mb
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
@pytest.fixture
|
|
@@ -107,3 +108,41 @@ def test_files_download_with_options(runner, tmp_path):
|
|
|
107
108
|
assert result.exit_code == 0
|
|
108
109
|
assert "File downloaded successfully!" in result.stdout
|
|
109
110
|
assert f"Saved to: '{(save_path / 'downloaded_file.txt')}'" in result.stdout.replace("\n", "")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_is_file_less_than_10mb_small_file(tmp_path):
|
|
114
|
+
"""Test is_file_less_than_10mb with a file smaller than 10MB."""
|
|
115
|
+
test_file = tmp_path / "small_file.txt"
|
|
116
|
+
test_file.write_text("Small file content") # Creates a small file
|
|
117
|
+
|
|
118
|
+
assert is_file_less_than_10mb(test_file) is True
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_is_file_less_than_10mb_large_file(tmp_path):
|
|
122
|
+
"""Test is_file_less_than_10mb with a file larger than 10MB."""
|
|
123
|
+
test_file = tmp_path / "large_file.txt"
|
|
124
|
+
|
|
125
|
+
# Mock the file stat to return size > 10MB
|
|
126
|
+
mock_stat = Mock()
|
|
127
|
+
mock_stat.st_size = 11 * 1024 * 1024 # 11MB
|
|
128
|
+
|
|
129
|
+
with patch.object(Path, "stat", return_value=mock_stat):
|
|
130
|
+
assert is_file_less_than_10mb(test_file) is False
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_is_file_less_than_10mb_nonexistent_file(tmp_path):
|
|
134
|
+
"""Test is_file_less_than_10mb with a nonexistent file."""
|
|
135
|
+
nonexistent_file = tmp_path / "nonexistent.txt"
|
|
136
|
+
assert is_file_less_than_10mb(nonexistent_file) is False
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_is_file_less_than_10mb_exactly_10mb(tmp_path):
|
|
140
|
+
"""Test is_file_less_than_10mb with a file exactly 10MB."""
|
|
141
|
+
test_file = tmp_path / "exact_10mb.txt"
|
|
142
|
+
|
|
143
|
+
# Mock the file stat to return size = 10MB
|
|
144
|
+
mock_stat = Mock()
|
|
145
|
+
mock_stat.st_size = 10 * 1024 * 1024 # 10MB
|
|
146
|
+
|
|
147
|
+
with patch.object(Path, "stat", return_value=mock_stat):
|
|
148
|
+
assert is_file_less_than_10mb(test_file) is False
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|