Пример #1
0
    def test_do_exploitation_no_records(self) -> None:
        """Tests on exploitation when no relevant records found."""
        predictor = TemporalDifference()
        assert predictor._policy == {}

        random_unresolved_dependency = (("tensorflow", "2.1.0",
                                         "https://thoth-station.ninja"), )

        state = flexmock()
        state.should_receive("iter_unresolved_dependencies").and_return([
            ("micropipenv", "0.1.4", "https://pypi.org/simple"),
            random_unresolved_dependency,
        ]).once()

        state.should_receive("get_random_unresolved_dependency").with_args(
            prefer_recent=True).and_return(
                random_unresolved_dependency).once()

        assert predictor._do_exploitation(
            state) == random_unresolved_dependency
Пример #2
0
    def test_do_exploitation(self) -> None:
        """Tests on exploitation computation."""
        predictor = TemporalDifference()
        predictor._policy = {
            ("tensorflow", "2.1.0", "https://thoth-station.ninja"):
            [2020.21, 666],
            ("tensorflow", "2.0.0", "https://thoth-station.ninja"):
            [16.61, 1992],
            ("numpy", "1.0.0", "https://pypi.org/simple"): [30.30, 92],
        }

        state = flexmock()
        state.should_receive("iter_unresolved_dependencies").and_return([
            ("spacy", "2.2.4", "https://pypi.org/simple"),
            ("numpy", "1.0.0", "https://pypi.org/simple"),
            ("tensorflow", "2.1.0", "https://thoth-station.ninja"),
        ]).once()

        state.should_receive("get_random_unresolved_dependency").times(0)
        assert predictor._do_exploitation(state) == (
            "tensorflow",
            "2.1.0",
            "https://thoth-station.ninja",
        )