Ejemplo n.º 1
0
    def test_resolve_upgrade_and_steps_with_resolution_disabled(
            self, upgrade_planer: UpgradePlaner, catalog):
        upgrade_planer.config['solve_dependencies'] = False
        upgrade_planer.build_catalog = mock.Mock(return_value=catalog)
        upgrade_planer.dependency_solver.solve_dependencies = mock.Mock(
            return_value={
                "results": [],
                "errors": [],
                "anomalies": []
            })
        bp = Phase(
            [PhasePin(catalog[1], "1.0.16"),
             PhasePin(catalog[0], "1.0.16")])
        upgrade_planer.get_latest_phase = mock.Mock(
            return_value={
                catalog[1]['name']: "1.0.16",
                catalog[0]['name']: "1.0.16"
            })
        upgrade_planer.solve_best_phase = mock.Mock(return_value=(bp, 1))
        upgrade_planer.build_steps = mock.Mock()

        res = upgrade_planer.resolve_upgrade_and_steps()

        upgrade_planer.solve_best_phase.assert_called_with([bp])
        upgrade_planer.build_steps.assert_called_with(bp)
        upgrade_planer.dependency_solver.solve_dependencies.assert_not_called()

        assert res['result']['best_phase'] == bp
Ejemplo n.º 2
0
    def test_resolve_upgrade_and_steps_with_goal(self,
                                                 upgrade_planer: UpgradePlaner,
                                                 catalog):
        upgrade_planer.build_catalog = mock.Mock(return_value=catalog)
        upgrade_planer.dependency_solver.solve_dependencies = mock.Mock(
            return_value={
                "results": [{
                    "producer": "1.0.16",
                    "consumer": "1.0.16"
                }],
                "errors": [],
                "anomalies": []
            })
        bp = Phase(
            [PhasePin(catalog[1], "1.0.16"),
             PhasePin(catalog[0], "1.0.16")])
        upgrade_planer.solve_best_phase = mock.Mock(return_value=(bp, 1))
        upgrade_planer.build_steps = mock.Mock()

        res = upgrade_planer.resolve_upgrade_and_steps()

        upgrade_planer.solve_best_phase.assert_called_with([bp])
        upgrade_planer.build_steps.assert_called_with(bp)

        assert res['result']['best_phase'] == bp
Ejemplo n.º 3
0
    def test_build_steps(self, upgrade_planer: UpgradePlaner):
        goal = Phase((
            PhasePin({
                "name": "producer",
            }, "1.0.17"),
            PhasePin({
                "name": "consumer",
            }, "1.0.17"),
        ))
        upgrade_planer.mongo.catalog.find.return_value = [{
            "name": "producer",
            "version": "1.0.16"
        }, {
            "name": "consumer",
            "version": "1.0.1"
        }]

        upgrade_planer.explain_phase = mock.Mock(return_value={'results': 0})
        s = upgrade_planer.build_steps(goal)
        assert 2 == len(s)
        assert [('producer', '1.0.16', '1.0.17'),
                ('consumer', '1.0.1', '1.0.17')] == s