def test_schedule_fail(self, record_tsm_mock): app_info = AppDryRunInfo("test", lambda x: "test") app_info._scheduler = "default" cfg = RunConfig({"image_fetcher": "dir"}) app_info._cfg = cfg session = DummySession("test_session") with self.assertRaises(RuntimeError): with patch.object(session, "_schedule") as schedule_mock: schedule_mock.side_effect = RuntimeError("test error") session.schedule(app_info) record_tsm_mock.assert_called()
def test_schedule_success(self, record_tsm_mock): app_info = AppDryRunInfo("test", lambda x: "test") app_info._scheduler = "default" cfg = RunConfig({"image_fetcher": "dir"}) app_info._cfg = cfg session = DummySession("test_session") app_handle = session.schedule(app_info) actual_tsm_event = record_tsm_mock.call_args[0][0] # first arg _, _, app_id = parse_app_handle(app_handle) self.assert_tsm_event( session._generate_tsm_event( "schedule", "default", app_id, runcfg=json.dumps(cfg.cfgs) ), actual_tsm_event, )