Skip to content

Commit

Permalink
Do not enable cut pre-releases step if selective pre-releases are all…
Browse files Browse the repository at this point in the history
…owed
  • Loading branch information
fridex committed Feb 9, 2021
1 parent b1ee024 commit b1e926e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions tests/sieves/test_prereleases.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ class TestCutPreReleasesSieve(AdviserUnitTestCase):
[pipenv]
allow_prereleases = true
"""

_CASE_SELECTIVE_PRERELEASES_ALLOWED_PIPFILE = """
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
tensorflow = "*"
[pipenv]
allow_prereleases = true
[thoth.allow_prereleases]
tensorflow = true
"""

@pytest.mark.parametrize(
Expand Down Expand Up @@ -115,6 +131,14 @@ def test_not_include(
assert builder_context.is_adviser_pipeline()
assert CutPreReleasesSieve.should_include(builder_context) is None

def test_not_include_thoth_prereleases_allowed(self, builder_context: PipelineBuilderContext) -> None:
"""Test not including this pipeline unit."""
builder_context.recommendation_type = RecommendationType.LATEST
builder_context.project = Project.from_strings(self._CASE_SELECTIVE_PRERELEASES_ALLOWED_PIPFILE)

assert builder_context.is_adviser_pipeline()
assert CutPreReleasesSieve.should_include(builder_context) is None

def test_verify_multiple_should_include(self, builder_context: PipelineBuilderContext) -> None:
"""Verify multiple should_include calls do not loop endlessly."""
builder_context.recommendation_type = RecommendationType.LATEST
Expand Down
4 changes: 3 additions & 1 deletion thoth/adviser/sieves/prereleases.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class CutPreReleasesSieve(Sieve):
@classmethod
def should_include(cls, builder_context: "PipelineBuilderContext") -> Optional[Dict[str, Any]]:
"""Include cut-prereleases pipeline sieve for adviser or Dependency Monkey if pre-releases are not allowed."""
if builder_context.project.prereleases_allowed:
if builder_context.project.prereleases_allowed or (
builder_context.project.pipfile.thoth and builder_context.project.pipfile.thoth.allow_prereleases
):
_LOGGER.info("Project accepts pre-releases, skipping cutting pre-releases step")
return None

Expand Down

0 comments on commit b1e926e

Please sign in to comment.