def test_unallowed_system_job_data(): sjt = SystemJobTemplate() accepted, ignored, errors = sjt.accept_or_ignore_variables({ 'days': 34, 'foobar': 'baz' }) assert 'foobar' in ignored assert 'days' in accepted
def test_reject_some_accept_some(): sjt = SystemJobTemplate() accepted, ignored, errors = sjt._accept_or_ignore_job_kwargs(limit="", extra_vars={ 'days': 34, 'foobar': 'baz' }) assert accepted == {"extra_vars": {"days": 34}} assert ignored == {"limit": "", "extra_vars": {"foobar": "baz"}} assert 'not allowed on launch' in errors['limit'][0]
def test_clean_extra_data_system_job(mocker): jt = SystemJobTemplate() schedule = Schedule(unified_job_template=jt) schedule._clean_extra_data_system_jobs = mocker.MagicMock() schedule.clean_extra_data() schedule._clean_extra_data_system_jobs.assert_called_once()
def test_reject_other_prommpts(): sjt = SystemJobTemplate() accepted, ignored, errors = sjt._accept_or_ignore_job_kwargs(limit="") assert accepted == {} assert 'not allowed on launch' in errors['limit'][0]
def test_invalid__extra_data_system_jobs(extra_data): accepted, rejected, errors = SystemJobTemplate( ).accept_or_ignore_variables(extra_data) assert str(errors['extra_vars'][0]) == u'days must be a positive integer.'
def test_valid__clean_extra_data_system_jobs(extra_data): accepted, rejected, errors = SystemJobTemplate( ).accept_or_ignore_variables(extra_data) assert not rejected assert not errors