def test_process_behavior_with_filenames(mocker, default_job): handler = mocker.Mock() handler.__name__ = 'CoverageHandler' handler.supported_types = frozenset([]) manager = Manager() manager.register(handler, ['coverage.xml']) artifact = factories.ArtifactFactory( job=default_job, name='junit.xml', ) artifact.file.save(BytesIO(), artifact.name) manager.process(artifact) assert not handler.called artifact = factories.ArtifactFactory( job=default_job, name='coverage.xml', ) artifact.file.save(BytesIO(), artifact.name) manager.process(artifact) handler.assert_called_once_with(default_job) handler.return_value.process.assert_called_once()
def test_update_job_to_finished_with_pending_artifacts( client, mocker, default_login, default_repo, default_build, default_job, default_repo_access, ): factories.ArtifactFactory(job=default_job, queued=True) assert default_job.result != Result.failed mock_delay = mocker.patch("zeus.tasks.aggregate_build_stats_for_job.delay") resp = client.put( "/api/repos/{}/builds/{}/jobs/{}".format(default_repo.get_full_name(), default_build.number, default_job.number), json={ "result": "failed", "status": "finished" }, ) assert resp.status_code == 200 data = resp.json() assert data["id"] == str(default_job.id) assert default_job.status == Status.collecting_results assert default_job.result == Result.failed mock_delay.assert_called_once_with(job_id=default_job.id)
def test_aggregates_upon_completion(mocker, default_job): manager = mocker.Mock() artifact = factories.ArtifactFactory(job=default_job, queued=True) process_artifact(artifact_id=artifact.id, manager=manager) assert artifact.status == Status.finished manager.process.assert_called_once_with(artifact)
def default_artifact(default_job): return factories.ArtifactFactory( job=default_job, name='junit.xml', )
def default_artifact(default_job): return factories.ArtifactFactory(job=default_job, )
def default_artifact(default_job): return factories.ArtifactFactory(job=default_job, name="junit.xml", finished=True)