def validate_job_name(cls, item): """Validates that the job_name field refers to an actual job. Args: item: beam_job_models.BeamJobRunModel. The item to validate. """ if item.job_name not in jobs_registry.get_all_job_names(): cls._add_error( 'beam_job_name_error', 'Entity id %s: The job_name field has a value %s which is ' 'not among the job names in jobs.registry.get_all_jobs()' % ( item.id, item.job_name))
def test_get_all_job_names_returns_value_from_job_metaclass(self): unique_obj = object() @classmethod def get_all_job_names_mock(unused_cls): """Returns the unique_obj.""" return unique_obj get_all_job_names_swap = self.swap(base_jobs.JobMetaclass, 'get_all_job_names', get_all_job_names_mock) with get_all_job_names_swap: self.assertIs(registry.get_all_job_names(), unique_obj)
def test_get_all_job_names_returns_value_from_job_metaclass(self) -> None: unique_obj = object() @classmethod # type: ignore[misc] def get_all_job_names_mock( unused_cls: Type[base_jobs.JobMetaclass]) -> object: """Returns the unique_obj.""" return unique_obj get_all_job_names_swap = self.swap(base_jobs.JobMetaclass, 'get_all_job_names', get_all_job_names_mock) with get_all_job_names_swap: self.assertIs(registry.get_all_job_names(), unique_obj)
def test_gets_jobs_from_registry(self): beam_jobs = beam_job_services.get_beam_jobs() self.assertItemsEqual([j.name for j in beam_jobs], jobs_registry.get_all_job_names())
def test_gets_jobs_from_registry(self) -> None: beam_jobs = beam_job_services.get_beam_jobs() self.assertItemsEqual( # type: ignore[no-untyped-call] [j.name for j in beam_jobs], jobs_registry.get_all_job_names())
def test_get_all_job_names_never_returns_an_empty_list(self): self.assertNotEqual(registry.get_all_job_names(), [])