@@ -20,6 +20,24 @@ def datetime_now() -> str:
2020 return "2024-10-04T12:00:00+00:00"
2121
2222
23+ @pytest .fixture (scope = "module" )
24+ def null_job_id () -> None :
25+ """A null job id."""
26+ return None
27+
28+
29+ @pytest .fixture (scope = "module" )
30+ def valid_job_id () -> str :
31+ """An existing valid job id."""
32+ return EntityIdGen .job_id ()
33+
34+
35+ @pytest .fixture (scope = "module" )
36+ def invalid_job_id () -> str :
37+ """An invalid job id."""
38+ return "invalid_job_id"
39+
40+
2341@pytest .fixture (scope = "module" , params = [DictStateBackend , RayStateBackend ])
2442def state_backend_cls (request : pytest .FixtureRequest ) -> _t .Type [StateBackend ]:
2543 """Returns a `StateBackend` class."""
@@ -28,22 +46,25 @@ def state_backend_cls(request: pytest.FixtureRequest) -> _t.Type[StateBackend]:
2846
2947@pytest .mark .asyncio
3048@pytest .mark .parametrize (
31- "job_id , metadata, exc_ctx" ,
49+ "job_id_fixture , metadata, exc_ctx" ,
3250 [
33- (None , None , None ),
34- (None , {"key" : "value" }, None ),
35- (EntityIdGen . job_id () , {"key" : "value" }, None ),
51+ ("null_job_id" , None , None ),
52+ ("null_job_id" , {"key" : "value" }, None ),
53+ ("valid_job_id" , {"key" : "value" }, None ),
3654 ("invalid_job_id" , None , pytest .raises (ValueError )),
3755 ],
3856)
3957async def test_state_backend_init (
4058 datetime_now : str ,
4159 state_backend_cls : _t .Type [StateBackend ],
42- job_id : _t . Optional [ str ] ,
60+ job_id_fixture : str ,
4361 metadata : _t .Optional [dict ],
4462 exc_ctx : AbstractContextManager ,
63+ request : pytest .FixtureRequest ,
4564) -> None :
4665 """Tests `StateBackend` initialisation."""
66+ job_id : _t .Optional [str ] = request .getfixturevalue (job_id_fixture )
67+
4768 state_backend = state_backend_cls (job_id = job_id , metadata = metadata )
4869
4970 with exc_ctx or nullcontext ():
0 commit comments