Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cran/tests/test_lister.py
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | for package_info in cran_data: | ||||
assert len(filtered_origins) == 1 | assert len(filtered_origins) == 1 | ||||
assert filtered_origins[0].extra_loader_arguments == { | assert filtered_origins[0].extra_loader_arguments == { | ||||
"artifacts": [{"url": artifact_url, "version": package_info["Version"]}] | "artifacts": [{"url": artifact_url, "version": package_info["Version"]}] | ||||
} | } | ||||
filtered_origins[0].last_update == parse_packaged_date(package_info) | filtered_origins[0].last_update == parse_packaged_date(package_info) | ||||
@pytest.mark.parametrize( | |||||
"credentials, expected_credentials", | |||||
[ | |||||
(None, []), | |||||
({"key": "value"}, []), | |||||
( | |||||
{"CRAN": {"cran": [{"username": "user", "password": "pass"}]}}, | |||||
[{"username": "user", "password": "pass"}], | |||||
), | |||||
], | |||||
) | |||||
def test_lister_cran_instantiation_with_credentials( | |||||
credentials, expected_credentials, swh_scheduler | |||||
): | |||||
lister = CRANLister(swh_scheduler, credentials=credentials) | |||||
# Credentials are allowed in constructor | |||||
assert lister.credentials == expected_credentials | |||||
def test_lister_cran_from_configfile(swh_scheduler_config, mocker): | |||||
load_from_envvar = mocker.patch("swh.lister.pattern.load_from_envvar") | |||||
load_from_envvar.return_value = { | |||||
"scheduler": {"cls": "local", **swh_scheduler_config}, | |||||
"credentials": {}, | |||||
} | |||||
lister = CRANLister.from_configfile() | |||||
assert lister.scheduler is not None | |||||
assert lister.credentials is not None |