62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from click.testing import CliRunner
|
|
|
|
import jprm
|
|
from .utils_test import json_load
|
|
from .utils_test import TEST_DATA_DIR
|
|
|
|
|
|
@pytest.mark.datafiles(
|
|
TEST_DATA_DIR / 'pluginA_1.0.0.zip',
|
|
TEST_DATA_DIR / 'manifest_pluginA.json',
|
|
) # type: ignore[untyped-decorator]
|
|
@pytest.mark.parametrize(
|
|
'url',
|
|
[
|
|
'http://example.org/plugins/pluginA_1.0.0.zip',
|
|
'https://example.org/pluginA.zip',
|
|
'https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu',
|
|
'ipfs://Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu',
|
|
'ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html',
|
|
],
|
|
) # type: ignore[untyped-decorator]
|
|
def test_repo_add_custom_url(
|
|
url: str,
|
|
cli_runner: CliRunner,
|
|
tmp_path: Path,
|
|
datafiles: Path,
|
|
caplog: pytest.LogCaptureFixture,
|
|
) -> None:
|
|
manifest_file = tmp_path / 'repo.json'
|
|
manifest_a = json_load(datafiles / 'manifest_pluginA.json')
|
|
manifest_a[0]['versions'][0]['sourceUrl'] = url
|
|
|
|
cli_runner.invoke(
|
|
jprm.cli,
|
|
[
|
|
'--verbosity=debug',
|
|
'repo',
|
|
'add',
|
|
str(manifest_file),
|
|
str(datafiles / 'pluginA_1.0.0.zip'),
|
|
'--plugin-url',
|
|
url,
|
|
],
|
|
)
|
|
manifest = json_load(manifest_file)
|
|
assert manifest == manifest_a
|
|
|
|
expected_log = (
|
|
'jprm',
|
|
logging.INFO,
|
|
f"Plugin url `{url}` overrides the autogenerated `https://///releases/download/1.0.0.0/plugin-a_1.0.0.0.zip`.",
|
|
)
|
|
assert expected_log in caplog.record_tuples
|
|
|
|
assert not (tmp_path / 'plugin-a' / 'plugin-a_1.0.0.0.zip').exists()
|