Exemplo n.º 1
0
    def test_handle_createrepo_failure_3(self, mc_createrepo, mc_time):
        mc_front_cb = MagicMock()
        tmp_dir = self.make_temp_dir()
        mc_createrepo.side_effect = [
            STDOUT,
            CreateRepoError("test exception", ["foo", "bar"], 1),
        ]

        action_data = json.dumps({
            "chroots": ["epel-6-i386", "fedora-20-x86_64"],
            "username": "******",
            "projectname": "bar"
        })
        self.opts.destdir = tmp_dir
        test_action = Action(
            opts=self.opts,
            action={
                "action_type": ActionType.CREATEREPO,
                "data": action_data,
                "id": 10
            },
            frontend_client=mc_front_cb,
        )
        test_action.run()

        result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]

        assert result_dict["id"] == 10
        assert result_dict["result"] == ActionResult.FAILURE
Exemplo n.º 2
0
    def test_prune_project_handle_errors(self, test_pruner, mc_cru, mc_gacs):
        self.pruner.prune_failed_builds = MagicMock()
        self.pruner.prune_obsolete_success_builds = MagicMock()
        mc_gacs.return_value = True

        #  0. createrepo_unsafe failure
        mc_cru.side_effect = CreateRepoError("test exception", ["foo", "bar"],
                                             1)

        self.pruner.prune_project(os.path.join(self.tmp_dir_name, self.prj),
                                  self.username, self.coprname)

        assert self.pruner.prune_failed_builds.called
        assert self.pruner.prune_obsolete_success_builds.called

        self.pruner.prune_failed_builds.reset_mock()
        self.pruner.prune_obsolete_success_builds.reset_mock()

        mc_cru.side_effect = None
        # 2. prune_obsolete_success_builds raises error

        self.pruner.prune_obsolete_success_builds.side_effect = IOError()

        self.pruner.prune_project(os.path.join(self.tmp_dir_name, self.prj),
                                  self.username, self.coprname)

        assert mc_cru.called

        self.pruner.prune_failed_builds.reset_mock()
        self.pruner.prune_obsolete_success_builds.reset_mock()
        mc_cru.reset_mock()

        # 3. prune_failed_builds raises error

        self.pruner.prune_obsolete_success_builds.side_effect = None
        self.pruner.prune_failed_builds.side_effect = IOError()

        self.pruner.prune_project(os.path.join(self.tmp_dir_name, self.prj),
                                  self.username, self.coprname)

        assert mc_cru.called