def main(config_path=None): client.sync_main( async_main, config_path=config_path, default_config=get_default_config(), should_validate_task=False, )
def main(config_path=None): data_dir = os.path.join(os.path.dirname(__file__), 'data') default_config = { 'schema_file': os.path.join(data_dir, 'beetmover_task_schema.json'), 'release_schema_file': os.path.join(data_dir, 'release_beetmover_task_schema.json'), 'maven_schema_file': os.path.join(data_dir, 'maven_beetmover_task_schema.json'), } # There are several task schema. Validation occurs in async_main client.sync_main(async_main, config_path=config_path, default_config=default_config, should_validate_task=False)
def main(config_path=None): data_dir = os.path.join(os.path.dirname(__file__), 'data') default_config = { 'schema_files': { 'submission': os.path.join(data_dir, 'bouncer_submission_task_schema.json'), 'aliases': os.path.join(data_dir, 'bouncer_aliases_task_schema.json'), 'locations': os.path.join(data_dir, 'bouncer_locations_task_schema.json'), } } client.sync_main(async_main, config_path=config_path, default_config=default_config, should_validate_task=False)
def main(config_path=None): data_dir = os.path.join(os.path.dirname(__file__), "data") default_config = { "schema_files": { "submission": os.path.join(data_dir, "bouncer_submission_task_schema.json"), "aliases": os.path.join(data_dir, "bouncer_aliases_task_schema.json"), "locations": os.path.join(data_dir, "bouncer_locations_task_schema.json"), } } client.sync_main(async_main, config_path=config_path, default_config=default_config, should_validate_task=False)
async def test_sync_main_runs_fully(config, should_validate_task): copyfile(BASIC_TASK, os.path.join(config['work_dir'], 'task.json')) async_main_calls = [] run_until_complete_calls = [] async def async_main(*args): async_main_calls.append(args) def count_run_until_complete(arg1): run_until_complete_calls.append(arg1) fake_loop = MagicMock() fake_loop.run_until_complete = count_run_until_complete def loop_function(): return fake_loop kwargs = {'loop_function': loop_function} if should_validate_task: schema_path = os.path.join(config['work_dir'], 'schema.json') copyfile(SCHEMA, schema_path) config['schema_file'] = schema_path else: # Task is validated by default kwargs['should_validate_task'] = False with tempfile.NamedTemporaryFile('w+') as f: json.dump(config, f) f.seek(0) kwargs['config_path'] = f.name client.sync_main(async_main, **kwargs) for i in run_until_complete_calls: await i # suppress coroutine not awaited warning assert len( run_until_complete_calls) == 1 # run_until_complete was called once assert len(async_main_calls) == 1 # async_main was called once
async def test_sync_main_runs_fully(config, should_validate_task): copyfile(BASIC_TASK, os.path.join(config['work_dir'], 'task.json')) async_main_calls = [] run_until_complete_calls = [] async def async_main(*args): async_main_calls.append(args) def count_run_until_complete(arg1): run_until_complete_calls.append(arg1) fake_loop = MagicMock() fake_loop.run_until_complete = count_run_until_complete def loop_function(): return fake_loop kwargs = {'loop_function': loop_function} if should_validate_task: schema_path = os.path.join(config['work_dir'], 'schema.json') copyfile(SCHEMA, schema_path) config['schema_file'] = schema_path else: # Task is validated by default kwargs['should_validate_task'] = False with tempfile.NamedTemporaryFile('w+') as f: json.dump(config, f) f.seek(0) kwargs['config_path'] = f.name client.sync_main(async_main, **kwargs) for i in run_until_complete_calls: await i # suppress coroutine not awaited warning assert len(run_until_complete_calls) == 1 # run_until_complete was called once assert len(async_main_calls) == 1 # async_main was called once
def main(config_path=None): return client.sync_main(async_main, config_path=config_path, default_config=get_default_config())
def main(config_path=None): client.sync_main(async_main, config_path=config_path, should_validate_task=False)
def main(config_path=None): # There are several task schema. Validation occurs in async_main client.sync_main(async_main, config_path=config_path, should_validate_task=False)