def test_invalid_json(self, get_build_step_for_job):
        buildstep = mock.Mock()
        get_build_step_for_job.return_value = (None, buildstep)
        project = self.create_project()
        build = self.create_build(project)
        job = self.create_job(build)
        jobphase = self.create_jobphase(job)
        jobstep = self.create_jobstep(jobphase)
        handler = CollectionArtifactHandler(jobstep)
        handler.FILENAMES = ('tests.json',)

        handler.process(StringIO(""))
        assert buildstep.call_count == 0
        assert FailureReason.query.filter(FailureReason.step_id == jobstep.id).first()
Beispiel #2
0
    def test_invalid_json(self, get_build_step_for_job):
        buildstep = mock.Mock()
        get_build_step_for_job.return_value = (None, buildstep)
        project = self.create_project()
        build = self.create_build(project)
        job = self.create_job(build)
        jobphase = self.create_jobphase(job)
        jobstep = self.create_jobstep(jobphase)
        handler = CollectionArtifactHandler(jobstep)
        handler.FILENAMES = ('tests.json', )

        handler.process(StringIO(""))
        assert buildstep.call_count == 0
        assert FailureReason.query.filter(
            FailureReason.step_id == jobstep.id).first()
    def test_valid_json(self, get_build_step_for_job):
        buildstep = mock.Mock()
        get_build_step_for_job.return_value = (None, buildstep)
        project = self.create_project()
        build = self.create_build(project)
        job = self.create_job(build)
        jobphase = self.create_jobphase(job)
        jobstep = self.create_jobstep(jobphase)
        handler = CollectionArtifactHandler(jobstep)
        handler.FILENAMES = ('/tests.json',)

        handler.process(StringIO("{}"))
        buildstep.expand_jobs.assert_called_once_with(jobstep, {})
        # make sure changes were committed
        db.session.rollback()
        assert not FailureReason.query.filter(FailureReason.step_id == jobstep.id).first()
Beispiel #4
0
    def test_valid_json(self, get_build_step_for_job):
        buildstep = mock.Mock()
        get_build_step_for_job.return_value = (None, buildstep)
        project = self.create_project()
        build = self.create_build(project)
        job = self.create_job(build)
        jobphase = self.create_jobphase(job)
        jobstep = self.create_jobstep(jobphase)
        handler = CollectionArtifactHandler(jobstep)
        handler.FILENAMES = ('tests.json',)

        handler.process(StringIO("{}"))
        buildstep.expand_jobs.assert_called_once_with(jobstep, {})
        # make sure changes were committed
        db.session.rollback()
        assert not FailureReason.query.filter(FailureReason.step_id == jobstep.id).first()
    def test_expand_jobs_error(self, get_build_step_for_job):
        buildstep = mock.Mock()
        get_build_step_for_job.return_value = (None, buildstep)
        project = self.create_project()
        build = self.create_build(project)
        job = self.create_job(build)
        jobphase = self.create_jobphase(job)
        jobstep = self.create_jobstep(jobphase)
        artifact = self.create_artifact(jobstep, 'tests.json')
        handler = CollectionArtifactHandler(jobstep)
        handler.FILENAMES = ('/tests.json', )
        buildstep.expand_jobs.side_effect = Exception('error')

        handler.process(StringIO("{}"), artifact)
        buildstep.expand_jobs.assert_called_once_with(jobstep, {})
        # make sure changes were committed
        db.session.rollback()
        assert jobstep.result == Result.infra_failed
        assert not FailureReason.query.filter(
            FailureReason.step_id == jobstep.id).first()