

@mock.patch.object(ArtifactHandler, 'process')
def test_process_behavior(self, process):

    class _CovHandler(ArtifactHandler):
        FILENAMES = ('coverage.xml',)

    class _OtherHandler(ArtifactHandler):
        FILENAMES = ('/other.xml',)
    manager = Manager([_CovHandler, _OtherHandler])
    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(step=jobstep, name='junit.xml')
    artifact.file.save(StringIO(), artifact.name)
    manager.process(artifact)
    assert (not process.called)
    artifact = self.create_artifact(step=jobstep, name='coverage.xml')
    artifact.file.save(StringIO(), artifact.name)
    manager.process(artifact)
    artifact = self.create_artifact(step=jobstep, name='foo/coverage.xml')
    artifact.file.save(StringIO(), artifact.name)
    manager.process(artifact)
    assert (process.call_count == 2)
    artifact = self.create_artifact(step=jobstep, name='artifactstore/other.xml')
    artifact.file.save(StringIO(), artifact.name)
    manager.process(artifact)
    assert (process.call_count == 3)
    artifact = self.create_artifact(step=jobstep, name='artifactstore/foo/other.xml')
    artifact.file.save(StringIO(), artifact.name)
    manager.process(artifact)
    assert (process.call_count == 3)

dataset/ETHPy150Open dropbox/changes/tests/changes/artifacts/test_manager.py ManagerTest.test_process_behavior/original