def test_validation2(): class MyJob(core4.queue.job.CoreJob): author = 'mra' defer_time = None job = MyJob() with pytest.raises(AssertionError): job.validate()
def test_validation(): class MyJob(core4.queue.job.CoreJob): author = 'mra' # defer_time = None hidden = True job = MyJob() job.validate() assert job.defer_time == 300 assert job.hidden is True
def test_invalid_extra_config(): class MyJob(core4.queue.job.CoreJob): author = "mra" def _make_config(self, *args, **kwargs): return core4.config.test.TestConfig(project_name="tests", project_dict={ "be": { "test_job": { "MyJob": { "defer_time": "abc" } } } }, **kwargs) job = MyJob() assert job.class_config.defer_time == "abc" with pytest.raises(AssertionError): job.validate()
def test_init(): job = core4.queue.job.CoreJob() with pytest.raises(AssertionError): job.validate() job = core4.queue.helper.job.example.DummyJob() assert job._id is None assert job.args == {} assert job.attempts == 1 assert job.attempts_left is None assert job.author == 'mra' assert job.chain == [] assert job.defer_max == 60 * 60 assert job.defer_time == 5 * 60 assert job.dependency == [] assert job.enqueued is None assert job.error_time == 10 * 60 assert job.finished_at is None assert job.inactive_at is None # assert job.inactive_time == 30 * 60 assert job.killed_at is None assert job.last_error is None assert job.locked is None assert job.max_parallel == 15 assert job.worker is None assert job.priority == 0 assert job.name == 'core4.queue.helper.job.example.DummyJob' assert job.query_at is None assert job.removed_at is None assert job.runtime is None assert job.schedule is None assert job.sources == [] assert job.started_at is None assert job.state is None assert job.tag is None assert job.wall_at is None assert job.wall_time is None