From 9dce2b6d3e99132aec3fe97e3b0b0c3a45f4216c Mon Sep 17 00:00:00 2001 From: Steve McGrath Date: Tue, 7 Jan 2025 17:44:00 -0600 Subject: [PATCH] Updated marketplace command to generate fake test data --- tenint/__init__.py | 2 +- tenint/cli.py | 21 +++++++++++++++------ tests/test_cli.py | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tenint/__init__.py b/tenint/__init__.py index da324a5..cd8c8dd 100644 --- a/tenint/__init__.py +++ b/tenint/__init__.py @@ -2,4 +2,4 @@ from .models.configuration import Configuration, Settings # noqa F401 from .connector import Connector # noqa F401 -__version__ = '0.1.7' +__version__ = "0.9.0" diff --git a/tenint/cli.py b/tenint/cli.py index 5034835..3f4ba12 100644 --- a/tenint/cli.py +++ b/tenint/cli.py @@ -116,11 +116,20 @@ def build_connector( @app.command('marketplace') def gen_marketplace( - image: Annotated[str, Option(..., help='Docker Image Name')], - icon: Annotated[str, Option(..., help='Icon Image URL')], + image: Annotated[ + str, Option(..., help='Docker Image Name') + ] = 'local/connector-example', + icon: Annotated[ + str, Option(..., help='Icon Image URL') + ] = 'https://nourl.example/logo.svg', path: Annotated[Path, Option(help='connector code path')] = Path('.'), + output: Annotated[Path, Option(help='output marketplace json file')] = None, ): - mpfile = path.joinpath('marketplace.json') - with mpfile.open('w', encoding='utf-8') as fobj: - mp = MarketplaceConnector.load_from_pyproject('pyproject.toml') - fobj.write(mp.model_dump_json()) + mpfile = path.joinpath('marketplace-object.json') + mp = MarketplaceConnector.load_from_pyproject( + filename='pyproject.toml', image_url=image, icon_url=icon + ).model_dump(mode='json') + console.print(mp) + if output: + with mpfile.open('w', encoding='utf-8') as fobj: + fobj.write(mp.model_dump_json()) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0939323..dd4223c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -21,7 +21,7 @@ def test_init_skip_single_file(tmp_path): result = runner.invoke(app, ['init', '--path', str(tmp_path)]) assert result.exit_code == 0 assert 'Now that you have' in result.stdout - assert 'pyproject.toml as it already exists' in result.stdout + assert 'pyproject.toml as it' in result.stdout def test_init_skip_tests(tmp_path):