def test_try_again(monkeypatch): push.push_to_try( "fuzzy", "Fuzzy message", try_task_config=push.generate_try_task_config( "fuzzy", ["foo", "bar"], {"use-artifact-builds": True}, ), ) assert os.path.isfile(push.history_path) with open(push.history_path, "r") as fh: assert len(fh.readlines()) == 1 def fake_push_to_try(*args, **kwargs): return args, kwargs monkeypatch.setattr(push, "push_to_try", fake_push_to_try) reload(again) args, kwargs = again.run() assert args[0] == "again" assert args[1] == "Fuzzy message" try_task_config = kwargs.pop("try_task_config") assert sorted(try_task_config.get("tasks")) == sorted(["foo", "bar"]) assert try_task_config.get("env") == {"TRY_SELECTOR": "fuzzy"} assert try_task_config.get('use-artifact-builds') with open(push.history_path, "r") as fh: assert len(fh.readlines()) == 1
def run(update=False, query=None, try_config=None, full=False, parameters=None, save=False, preset=None, mod_presets=False, push=True, message='{msg}', closed_tree=False): from .app import create_application check_working_directory(push) tg = generate_tasks(parameters, full) app = create_application(tg) if os.environ.get('WERKZEUG_RUN_MAIN') == 'true': # we are in the reloader process, don't open the browser or do any try stuff app.run() return # give app a second to start before opening the browser url = 'http://127.0.0.1:5000' Timer(1, lambda: webbrowser.open(url)).start() print("Starting trychooser on {}".format(url)) app.run() selected = app.tasks if not selected: print("no tasks selected") return msg = "Try Chooser Enhanced ({} tasks selected)".format(len(selected)) return push_to_try('chooser', message.format(msg=msg), try_task_config=generate_try_task_config('chooser', selected, try_config), push=push, closed_tree=closed_tree)
def run( update=False, query=None, try_config=None, full=False, parameters=None, save=False, preset=None, mod_presets=False, push=True, message="{msg}", closed_tree=False, ): from .app import create_application check_working_directory(push) tg = generate_tasks(parameters, full) # Remove tasks that are not to be shown unless `--full` is specified. if not full: blacklisted_tasks = [ label for label in tg.tasks.keys() if not filter_by_uncommon_try_tasks(label) ] for task in blacklisted_tasks: tg.tasks.pop(task) app = create_application(tg) if os.environ.get("WERKZEUG_RUN_MAIN") == "true": # we are in the reloader process, don't open the browser or do any try stuff app.run() return # give app a second to start before opening the browser url = "http://127.0.0.1:5000" Timer(1, lambda: webbrowser.open(url)).start() print("Starting trychooser on {}".format(url)) app.run() selected = app.tasks if not selected: print("no tasks selected") return msg = "Try Chooser Enhanced ({} tasks selected)".format(len(selected)) return push_to_try( "chooser", message.format(msg=msg), try_task_config=generate_try_task_config("chooser", selected, try_config), push=push, closed_tree=closed_tree, )
def test_no_push_does_not_generate_history(tmpdir): assert not os.path.isfile(push.history_path) push.push_to_try( "fuzzy", "Fuzzy", try_task_config=push.generate_try_task_config( "fuzzy", ["foo", "bar"], {"use-artifact-builds": True}, ), push=False, ) assert not os.path.isfile(push.history_path) assert again.run() == 1