Ejemplo n.º 1
0
 def test_update_config(self):
     YAML_BEFORE = textwrap.dedent("""\
         z_first:
           unrelated: dict
         a_second:
           key1: val1
           # some comment
           key2: val2
     """)
     YAML_EXPECTED = textwrap.dedent("""\
         z_first:
           unrelated: dict
         a_second:
           key1: newval1
           # some comment
           key2: val2
           key3: val3
     """)
     runner = CliRunner()
     with runner.isolated_filesystem():
         with open('conf.yml', 'w') as f:
             f.write(YAML_BEFORE)
         with update_config('conf.yml') as conf:
             conf['a_second']['key1'] = 'newval1'
             conf['a_second']['key3'] = 'val3'
         with open('conf.yml', 'r') as f:
             self.assertEqual(f.read(), YAML_EXPECTED)
Ejemplo n.º 2
0
def cli():
    global_conf = load_shub_config(load_local=False, load_env=False)
    if 'default' not in global_conf.apikeys:
        click.echo("You are not logged in.")
        return 0

    with update_config() as conf:
        del conf['apikeys']['default']