Skip to content

Commit

Permalink
Support + test source_url/download_url combinations (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer authored Apr 29, 2021
1 parent 960de96 commit f4af971
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ from `deprecated_decorators.py` to `_config_parser.py`. Simplified deprecation w
`deprecated_plugin` decorator with `Type[WebvizPluginABC]`.
- [#433](https://github.com/equinor/webviz-config/pull/433) - Removed short message
from `deprecated_plugin` decorator.
- [#435](https://github.com/equinor/webviz-config/pull/435) - Support only specifying
`source_url` in `setup.py` when building Dockerfile.

## [0.3.0] - 2021-04-27

Expand Down
50 changes: 50 additions & 0 deletions tests/test_docker_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import pytest

from webviz_config._dockerize._create_docker_setup import get_python_requirements


@pytest.mark.parametrize(
"distributions, requirements",
[
(
{
"webviz-config": {
"download_url": "https://pypi.org/project/webviz-config",
"source_url": None,
"dist_version": "0.3.0",
}
},
["webviz-config==0.3.0"],
),
(
{
"webviz-config": {
"download_url": None,
"source_url": None,
"dist_version": "0.3.0",
}
},
[],
),
(
{
"webviz-config": {
"download_url": None,
"source_url": "https://github.com/equinor/webviz-config",
"dist_version": "0.3.0",
}
},
["git+https://github.com/equinor/[email protected]"],
),
],
)
def test_derived_requirements(distributions, requirements):
with pytest.warns(None) as record:
assert requirements == get_python_requirements(distributions)
assert len(record) == len(
[
metadata
for metadata in distributions.values()
if metadata["download_url"] is None and metadata["source_url"] is None
]
)
4 changes: 3 additions & 1 deletion webviz_config/_dockerize/_create_docker_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def get_python_requirements(distributions: dict) -> List[str]:
)
continue

if dist["download_url"].startswith(PYPI_URL_ROOT):
if dist["download_url"] is not None and dist["download_url"].startswith(
PYPI_URL_ROOT
):
pypi_data = requests.get(f"{PYPI_URL_ROOT}/pypi/{dist_name}/json").json()
if dist["dist_version"] in pypi_data["releases"]:
requirements.append(f"{dist_name}=={dist['dist_version']}")
Expand Down

0 comments on commit f4af971

Please sign in to comment.