Пример #1
0
 def may_give_Connection_init_kwarg_dicts(self, remote):
     remote.expect_sessions(
         Session("host1", user="******", cmd="nope"),
         Session("host2", cmd="nope"),
     )
     with cd(support):
         program.run("fab hosts-are-init-kwargs")
Пример #2
0
 def dash_i_supplies_default_connect_kwarg_key_filename(self):
     # NOTE: the expect-identity task in tests/_support/fabfile.py
     # performs asserts about its context's .connect_kwargs value,
     # relying on other tests to prove connect_kwargs makes its way into
     # that context.
     with cd(support):
         program.run("fab -i identity.key expect-identity")
Пример #3
0
 def single_string_is_single_host_and_single_exec(self, remote):
     remote.expect(host="myhost", cmd="nope")
     # In addition to just testing a base case, this checks for a really
     # dumb bug where one appends to, instead of replacing, the task
     # list during parameterization/expansion XD
     with cd(support):
         program.run("fab -H myhost basic-run")
Пример #4
0
 def key_filename_can_be_set_via_non_override_config_levels(self):
     # Proves/protects against #1762, where eg key_filenames gets
     # 'reset' to an empty list. Arbitrarily uses the 'yml' level of
     # test fixtures, which has a fabric.yml w/ a
     # connect_kwargs.key_filename value of [private.key, other.key].
     with cd(os.path.join(support, "yml_conf")):
         program.run("fab expect-conf-key-filename")
Пример #5
0
 def may_give_mixed_value_types(self, remote):
     remote.expect_sessions(
         Session("host1", user="******", cmd="nope"),
         Session("host2", cmd="nope"),
     )
     with cd(support):
         program.run("fab hosts-are-mixed-values")
Пример #6
0
def main():
    sys.argv = [
        'fab', '-r',
        str(Path(__file__).parent), '-F', 'nested', '--echo'
    ] + sys.argv[1:]
    if len(sys.argv) == 6:
        sys.argv += ['--list']
    program.run()
Пример #7
0
 def _expect_prompt(self, getpass, flag, key, value, prompt):
     getpass.return_value = value
     with cd(support):
         # Expect that the given key was found in the context.
         cmd = "fab -c prompting {} expect-connect-kwarg --key {} --val {}"  # noqa
         program.run(cmd.format(flag, key, value))
     # Then we also expect that getpass was called w/ expected prompt
     getpass.assert_called_once_with(prompt)
Пример #8
0
 def complete_flag_does_not_trigger_remainder_only_behavior(self):
     # When bug present, 'fab --complete -- fab' fails to load any
     # collections because it thinks it's in remainder-only,
     # work-without-a-collection mode.
     with cd(support):
         program.run("fab --complete -- fab", exit=False)
     # Cherry-picked sanity checks looking for tasks from fixture
     # fabfile
     output = sys.stdout.getvalue()
     for name in ("build", "deploy", "expect-from-env"):
         assert name in output
Пример #9
0
 def _run(
     self,
     flag="-S",
     file_="ssh_config/runtime.conf",
     tasks="runtime-ssh-config",
 ):
     with cd(support):
         # Relies on asserts within the task, which will bubble up as
         # it's executed in-process
         cmd = "fab -c runtime_fabfile {} {} -H runtime {}"
         program.run(cmd.format(flag, file_, tasks))
Пример #10
0
        def pre_post_tasks_are_not_parameterized_across_hosts(self):
            with cd(support):
                program.run("fab -H hostA,hostB,hostC second --show-host")
                output = sys.stdout.getvalue()
                # Expect pre once, 3x main, post once, as opposed to e.g. both
                # pre and main task
                expected = """
First!
Second: hostA
Second: hostB
Second: hostC
Third!
""".lstrip()
                assert output == expected
Пример #11
0
 def double_dash_identity_also_works(self):
     with cd(support):
         program.run("fab --identity identity.key expect-identity")
Пример #12
0
 def loads_fabric_config_files_not_invoke_ones(self):
     for type_ in ("yaml", "yml", "json", "py"):
         with cd(os.path.join(support, "{}_conf".format(type_))):
             # This task, in each subdir, expects data present in a
             # fabric.<ext> nearby to show up in the config.
             program.run("fab expect-conf-value")
Пример #13
0
 def invokelike_multitask_invocation_preserves_config_mutation(self):
     # Mostly a guard against Executor subclass tweaks breaking Invoke
     # behavior added in pyinvoke/invoke#309
     with cd(support):
         program.run("fab mutate expect-mutation")
Пример #14
0
 def multiple_hosts_works_with_remainder_too(self, remote):
     remote.expect_sessions(
         Session("host1", cmd="whoami"), Session("host2", cmd="whoami")
     )
     program.run("fab -H host1,host2 -- whoami")
Пример #15
0
 def uses_FABRIC_env_prefix(self, environ):
     environ["FABRIC_RUN_ECHO"] = "1"
     with cd(support):
         program.run("fab expect-from-env")
Пример #16
0
def main():
    """Entry point."""
    os.chdir(os.path.dirname(__file__))
    logging.config.fileConfig("logging.ini")
    program.run()
Пример #17
0
 def host_string_shorthand_works_ok(self, remote):
     remote.expect(host="host1", port=1234, user="******")
     with cd(support):
         program.run("fab hosts-are-host-stringlike")
Пример #18
0
 def multiple_strings_is_multiple_host_args(self, remote):
     remote.expect_sessions(
         Session("host1", cmd="nope"), Session("host2", cmd="nope")
     )
     with cd(support):
         program.run("fab two-hosts")
Пример #19
0
 def single_string_is_single_exec(self, remote):
     remote.expect(host="myhost", cmd="nope")
     with cd(support):
         program.run("fab hosts-are-myhost")
Пример #20
0
 def config_mutation_not_preserved(self):
     with cd(support):
         program.run("fab -H host1,host2 expect-mutation-to-fail")
Пример #21
0
 def host_string_shorthand_is_passed_through(self, remote):
     remote.expect(host="host1", port=1234, user="******")
     program.run("fab -H someuser@host1:1234 -- whoami")
Пример #22
0
 def may_be_given_multiple_times(self):
     with cd(support):
         program.run(
             "fab -i identity.key -i identity2.key expect-identities"
         )
Пример #23
0
def _run_fab(argstr, **kwargs):
    cmd = "fab -f {} {}".format(config_file, argstr)
    return fab_program.run(cmd, **kwargs)
Пример #24
0
 def calls_task_once_with_invoke_context(self):
     with cd(support):
         program.run("fab expect-vanilla-Context")
Пример #25
0
 def cli_identity_still_overrides_when_non_empty(self):
     with cd(os.path.join(support, "yml_conf")):
         program.run("fab -i cli.key expect-cli-key-filename")
Пример #26
0
 def vanilla_Invoke_task_works_too(self):
     with cd(support):
         program.run("fab vanilla-Task-works-ok")
Пример #27
0
 def executes_remainder_as_anonymous_task(self, remote):
     remote.expect(host="myhost", cmd="whoami")
     program.run("fab -H myhost -- whoami", exit=False)
Пример #28
0
 def generates_exception_if_combined_with_remainder(self):
     program.run("fab -- nope")
Пример #29
0
def _run_fab(argstr, **kwargs):
    cmd = "fab -f {} {}".format(config_file, argstr)
    return fab_program.run(cmd, **kwargs)
Пример #30
0
 def comma_separated_string_is_multiple_hosts(self, remote):
     remote.expect_sessions(
         Session("host1", cmd="nope"), Session("host2", cmd="nope")
     )
     with cd(support):
         program.run("fab -H host1,host2 basic-run")