diff --git a/brewtils/models.py b/brewtils/models.py index fe104a40..99cda6e4 100644 --- a/brewtils/models.py +++ b/brewtils/models.py @@ -1414,7 +1414,7 @@ def __str__(self): return repr(self) def __repr__(self): - return "" % ( + return "" % ( self.pattern, self.path, self.recursive, diff --git a/brewtils/test/comparable.py b/brewtils/test/comparable.py index 1dda4a73..f8c3c3f1 100644 --- a/brewtils/test/comparable.py +++ b/brewtils/test/comparable.py @@ -20,6 +20,7 @@ CronTrigger, DateTrigger, Event, + FileTrigger, Garden, Instance, IntervalTrigger, @@ -191,7 +192,8 @@ def _assert_wrapper(obj1, obj2, expected_type=None, do_raise=False, **kwargs): assert_queue_equal = partial(_assert_wrapper, expected_type=Queue) assert_request_template_equal = partial(_assert_wrapper, expected_type=RequestTemplate) assert_trigger_equal = partial( - _assert_wrapper, expected_type=(CronTrigger, DateTrigger, IntervalTrigger) + _assert_wrapper, + expected_type=(CronTrigger, DateTrigger, FileTrigger, IntervalTrigger), ) assert_request_file_equal = partial(_assert_wrapper, expected_type=RequestFile) assert_runner_equal = partial(_assert_wrapper, expected_type=Runner) diff --git a/brewtils/test/fixtures.py b/brewtils/test/fixtures.py index 3996cc8b..084417bd 100644 --- a/brewtils/test/fixtures.py +++ b/brewtils/test/fixtures.py @@ -13,6 +13,7 @@ CronTrigger, DateTrigger, Event, + FileTrigger, Garden, Instance, IntervalTrigger, @@ -608,6 +609,15 @@ def cron_job_dict(job_dict, cron_trigger_dict): return dict_copy +@pytest.fixture +def file_job_dict(job_dict, file_trigger_dict): + """A file job represented as a dictionary.""" + dict_copy = copy.deepcopy(job_dict) + dict_copy["trigger_type"] = "file" + dict_copy["trigger"] = file_trigger_dict + return dict_copy + + @pytest.fixture def interval_job_dict(job_dict, interval_trigger_dict): """An interval job represented as a dictionary.""" @@ -659,6 +669,16 @@ def bg_cron_job(cron_job_dict, bg_request_template, bg_cron_trigger, ts_dt): return Job(**dict_copy) +@pytest.fixture +def bg_file_job(file_job_dict, bg_request_template, bg_file_trigger): + """A beer garden interval job""" + dict_copy = copy.deepcopy(file_job_dict) + dict_copy["next_run_time"] = None + dict_copy["trigger"] = bg_file_trigger + dict_copy["request_template"] = bg_request_template + return Job(**dict_copy) + + @pytest.fixture def bg_interval_job(interval_job_dict, bg_request_template, bg_interval_trigger, ts_dt): """A beer garden interval job""" @@ -756,6 +776,23 @@ def bg_date_trigger(date_trigger_dict, ts_dt): return DateTrigger(**dict_copy) +@pytest.fixture +def file_trigger_dict(): + """A file trigger as a dictionary""" + return { + "path": "./input", + "pattern": "*", + "recursive": False, + } + + +@pytest.fixture +def bg_file_trigger(file_trigger_dict): + """A file trigger as a model""" + dict_copy = copy.deepcopy(file_trigger_dict) + return FileTrigger(**dict_copy) + + @pytest.fixture def bg_request_file(request_file_dict): """A request file as a model""" diff --git a/test/models_test.py b/test/models_test.py index ec3f40dc..93c6b863 100644 --- a/test/models_test.py +++ b/test/models_test.py @@ -566,6 +566,15 @@ def test_scheduler_kwargs(self, bg_date_trigger, ts_dt_utc): } +class TestFileTrigger(object): + def test_schedule_kwargs_default(self, bg_file_trigger): + assert bg_file_trigger.scheduler_kwargs == { + "path": "./input", + "pattern": "*", + "recursive": False, + } + + class TestIntervalTrigger(object): def test_scheduler_kwargs_default(self): assert IntervalTrigger(timezone="utc").scheduler_kwargs == { @@ -631,6 +640,11 @@ def test_scheduler_kwargs( "", "", ), + ( + lazy_fixture("bg_file_trigger"), + "", + "", + ), ( lazy_fixture("bg_interval_trigger"), "",