Пример #1
0
 def test_invalid_context_no_type(self) -> None:
     """Exactly one type (recommendation/decision) has to be provided on instantiation."""
     with pytest.raises(ValueError):
         Context(
             project=None,
             graph=None,
             library_usage=None,
             limit=None,
             count=None,
             beam=None,
             # Decision type and recommendation type cannot be set to None at the same time.
             recommendation_type=None,
             decision_type=None,
         )
Пример #2
0
 def test_invalid_context_type(self) -> None:
     """Context type cannot capture both adviser and dependency monkey type."""
     with pytest.raises(ValueError):
         Context(
             project=None,
             graph=None,
             library_usage=None,
             limit=None,
             count=None,
             beam=None,
             # Decision type and recommendation type cannot be set at the same time.
             recommendation_type=RecommendationType.LATEST,
             decision_type=DecisionType.ALL,
         )
Пример #3
0
def context(project: Project) -> Context:
    """A fixture for a clean context."""
    flexmock(Context)
    flexmock(Beam)
    flexmock(GraphDatabase)

    return Context(
        project=project,
        graph=GraphDatabase(),
        library_usage=None,
        limit=100,
        count=3,
        beam=Beam(),
        recommendation_type=RecommendationType.LATEST,
    )
Пример #4
0
    def test_is_adviser(self) -> None:
        """Test checking if the given context is an adviser context."""
        context = Context(
            project=None,
            graph=None,
            library_usage=None,
            limit=None,
            count=None,
            beam=None,
            recommendation_type=RecommendationType.LATEST,
            decision_type=None,
        )

        assert context.is_adviser() is True
        assert context.is_dependency_monkey() is False