amazon-sp-cli 0.2.9__tar.gz → 0.3.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.
- {amazon_sp_cli-0.2.9/amazon_sp_cli.egg-info → amazon_sp_cli-0.3.0}/PKG-INFO +1 -1
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/__init__.py +1 -1
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/cli.py +2 -0
- amazon_sp_cli-0.3.0/amazon_sp_cli/commands/update.py +34 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/main.py +2 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0/amazon_sp_cli.egg-info}/PKG-INFO +1 -1
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli.egg-info/SOURCES.txt +3 -1
- amazon_sp_cli-0.3.0/tests/test_update.py +55 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/LICENSE +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/MANIFEST.in +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/README.md +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/__main__.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/auth.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/client.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/commands/__init__.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/commands/a_plus.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/commands/auth.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/commands/inventory.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/commands/listings.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/commands/pricing.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/models/__init__.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli/models/a_plus.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli.egg-info/dependency_links.txt +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli.egg-info/entry_points.txt +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli.egg-info/requires.txt +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/amazon_sp_cli.egg-info/top_level.txt +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/pyproject.toml +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/setup.cfg +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/setup.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/__init__.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/test_a_plus.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/test_auth.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/test_client.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/test_inventory.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/test_listings.py +0 -0
- {amazon_sp_cli-0.2.9 → amazon_sp_cli-0.3.0}/tests/test_pricing.py +0 -0
|
@@ -8,6 +8,7 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
import click
|
|
10
10
|
|
|
11
|
+
from . import __version__
|
|
11
12
|
from .auth import SPAPIAuth
|
|
12
13
|
from .client import SPAPIClient
|
|
13
14
|
|
|
@@ -82,6 +83,7 @@ def handle_errors(f):
|
|
|
82
83
|
return wrapper
|
|
83
84
|
|
|
84
85
|
|
|
86
|
+
@click.version_option(version=__version__, prog_name="amz-sp")
|
|
85
87
|
@click.group()
|
|
86
88
|
@click.option("--credentials", "-c", help="Path to credentials YAML file")
|
|
87
89
|
@click.pass_context
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Self-update command."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
|
|
8
|
+
from ..cli import handle_errors
|
|
9
|
+
|
|
10
|
+
PACKAGE_NAME = "amazon-sp-cli"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def register_update_commands(cli_group):
|
|
14
|
+
"""Register update CLI commands."""
|
|
15
|
+
|
|
16
|
+
@cli_group.command()
|
|
17
|
+
@click.option("--dry-run", is_flag=True, help="Show the command without running it")
|
|
18
|
+
@handle_errors
|
|
19
|
+
def update(dry_run):
|
|
20
|
+
"""Update to the latest version from PyPI."""
|
|
21
|
+
cmd = [sys.executable, "-m", "pip", "install", "--upgrade", PACKAGE_NAME]
|
|
22
|
+
|
|
23
|
+
if dry_run:
|
|
24
|
+
click.echo("Would run: " + " ".join(cmd))
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
click.echo("Updating amazon-sp-cli...")
|
|
28
|
+
result = subprocess.run(cmd, capture_output=False)
|
|
29
|
+
|
|
30
|
+
if result.returncode != 0:
|
|
31
|
+
click.echo("Update failed.", err=True)
|
|
32
|
+
raise click.Abort()
|
|
33
|
+
|
|
34
|
+
click.echo("Update complete. Run 'amz-sp --version' to verify.")
|
|
@@ -6,9 +6,11 @@ from .commands.auth import register_auth_commands
|
|
|
6
6
|
from .commands.inventory import register_inventory_commands
|
|
7
7
|
from .commands.listings import register_listings_commands
|
|
8
8
|
from .commands.pricing import register_pricing_commands
|
|
9
|
+
from .commands.update import register_update_commands
|
|
9
10
|
|
|
10
11
|
register_auth_commands(cli)
|
|
11
12
|
register_listings_commands(cli, _ensure_auth_client)
|
|
12
13
|
register_pricing_commands(cli, _ensure_auth_client)
|
|
13
14
|
register_a_plus_commands(cli, _ensure_auth_client)
|
|
14
15
|
register_inventory_commands(cli, _ensure_auth_client)
|
|
16
|
+
register_update_commands(cli)
|
|
@@ -21,6 +21,7 @@ amazon_sp_cli/commands/auth.py
|
|
|
21
21
|
amazon_sp_cli/commands/inventory.py
|
|
22
22
|
amazon_sp_cli/commands/listings.py
|
|
23
23
|
amazon_sp_cli/commands/pricing.py
|
|
24
|
+
amazon_sp_cli/commands/update.py
|
|
24
25
|
amazon_sp_cli/models/__init__.py
|
|
25
26
|
amazon_sp_cli/models/a_plus.py
|
|
26
27
|
tests/__init__.py
|
|
@@ -29,4 +30,5 @@ tests/test_auth.py
|
|
|
29
30
|
tests/test_client.py
|
|
30
31
|
tests/test_inventory.py
|
|
31
32
|
tests/test_listings.py
|
|
32
|
-
tests/test_pricing.py
|
|
33
|
+
tests/test_pricing.py
|
|
34
|
+
tests/test_update.py
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Tests for update and version commands."""
|
|
2
|
+
|
|
3
|
+
from unittest.mock import patch
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
from click.testing import CliRunner
|
|
7
|
+
|
|
8
|
+
from amazon_sp_cli import __version__
|
|
9
|
+
from amazon_sp_cli.main import cli
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestUpdate:
|
|
13
|
+
"""Test self-update command."""
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
def runner(self):
|
|
17
|
+
"""Create Click test runner."""
|
|
18
|
+
return CliRunner()
|
|
19
|
+
|
|
20
|
+
@patch("amazon_sp_cli.commands.update.subprocess.run")
|
|
21
|
+
def test_update(self, mock_run, runner):
|
|
22
|
+
"""Test update command succeeds."""
|
|
23
|
+
mock_run.return_value.returncode = 0
|
|
24
|
+
|
|
25
|
+
result = runner.invoke(cli, ["update"])
|
|
26
|
+
|
|
27
|
+
assert result.exit_code == 0
|
|
28
|
+
assert "Updating amazon-sp-cli" in result.output
|
|
29
|
+
mock_run.assert_called_once()
|
|
30
|
+
args = mock_run.call_args[0][0]
|
|
31
|
+
assert args[-1] == "amazon-sp-cli"
|
|
32
|
+
|
|
33
|
+
@patch("amazon_sp_cli.commands.update.subprocess.run")
|
|
34
|
+
def test_update_failure(self, mock_run, runner):
|
|
35
|
+
"""Test update command aborts on failure."""
|
|
36
|
+
mock_run.return_value.returncode = 1
|
|
37
|
+
|
|
38
|
+
result = runner.invoke(cli, ["update"])
|
|
39
|
+
|
|
40
|
+
assert result.exit_code != 0
|
|
41
|
+
|
|
42
|
+
def test_update_dry_run(self, runner):
|
|
43
|
+
"""Test update --dry-run prints command without running."""
|
|
44
|
+
result = runner.invoke(cli, ["update", "--dry-run"])
|
|
45
|
+
|
|
46
|
+
assert result.exit_code == 0
|
|
47
|
+
assert "Would run:" in result.output
|
|
48
|
+
assert "amazon-sp-cli" in result.output
|
|
49
|
+
|
|
50
|
+
def test_version_flag(self, runner):
|
|
51
|
+
"""Test --version outputs version."""
|
|
52
|
+
result = runner.invoke(cli, ["--version"])
|
|
53
|
+
|
|
54
|
+
assert result.exit_code == 0
|
|
55
|
+
assert f"amz-sp, version {__version__}" in result.output
|
|
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
|