예제 #1
0
파일: test_job.py 프로젝트: kbase/narrative
    def test_job_init__from_job_id(self):
        """
        test job initialisation, as is done by run_app
        """
        for job_id in ALL_JOBS:
            if job_id == BATCH_PARENT:
                continue

            with mock.patch(CLIENTS, get_mock_client):
                job = Job.from_job_id(job_id)
            self.check_job_attrs(job, job_id)
예제 #2
0
파일: test_job.py 프로젝트: kbase/narrative
def get_batch_family_jobs(return_list=False):
    """
    As invoked in appmanager's run_app_batch, i.e.,
    with from_job_id(s)
    """
    child_jobs = Job.from_job_ids(BATCH_CHILDREN, return_list=True)
    batch_job = Job.from_job_id(BATCH_PARENT, children=child_jobs)

    if return_list:
        return [batch_job] + child_jobs
    else:
        return {
            BATCH_PARENT: batch_job,
            **{
                child_id: child_job
                for child_id, child_job in zip(BATCH_CHILDREN, child_jobs)
            },
        }
예제 #3
0
파일: test_job.py 프로젝트: kbase/narrative
    def test_parent_children__ok(self):
        child_jobs = [Job.from_job_id(job_id) for job_id in BATCH_CHILDREN]
        parent_job = Job(
            create_state_from_ee2(BATCH_PARENT),
            children=child_jobs,
        )

        self.assertFalse(parent_job.was_terminal())

        # Make all child jobs completed
        with mock.patch.object(
            MockClients,
            "check_job",
            mock.Mock(return_value={"status": COMPLETED_STATUS}),
        ):
            for child_job in child_jobs:
                child_job.state(force_refresh=True)

        self.assertTrue(parent_job.was_terminal())
예제 #4
0
파일: test_job.py 프로젝트: kbase/narrative
    def test_job_init__extra_state(self):
        """
        test job initialisation as is done by run_legacy_batch_app
        """

        app_id = "kb_BatchApp/run_batch"
        extra_data = {
            "batch_app": app_id,
            "batch_tag": None,
            "batch_size": 300,
        }

        for job_id in ALL_JOBS:
            if job_id == BATCH_PARENT:
                continue

            with mock.patch(CLIENTS, get_mock_client):
                batch_job = Job.from_job_id(
                    job_id,
                    extra_data=extra_data,
                )

            self.check_job_attrs(batch_job, job_id, {"extra_data": extra_data})