Beispiel #1
0
def test_build_default_map():
    empty_cfg = configparser.ConfigParser()
    empty_conf = Config("foobar", empty_cfg)

    default_map = {
        "following": {
            "check": empty_conf.check_following,
            "timeout": empty_conf.timeout,
            "porcelain": empty_conf.porcelain,
        },
        "tweet": {
            "twtfile": empty_conf.twtfile,
        },
        "timeline": {
            "pager": empty_conf.use_pager,
            "cache": empty_conf.use_cache,
            "limit": empty_conf.limit_timeline,
            "timeout": empty_conf.timeout,
            "sorting": empty_conf.sorting,
            "porcelain": empty_conf.porcelain,
            "twtfile": empty_conf.twtfile,
        },
        "view": {
            "pager": empty_conf.use_pager,
            "cache": empty_conf.use_cache,
            "limit": empty_conf.limit_timeline,
            "timeout": empty_conf.timeout,
            "sorting": empty_conf.sorting,
            "porcelain": empty_conf.porcelain,
        }
    }

    assert empty_conf.build_default_map() == default_map
Beispiel #2
0
def quickstart(ctx):
    """Quickstart wizard for setting up twtxt."""
    width = click.get_terminal_size()[0]
    width = width if width <= 79 else 79

    click.secho("twtxt - quickstart", fg="cyan")
    click.secho("==================", fg="cyan")
    click.echo()

    help = "This wizard will generate a basic configuration file for twtxt with all mandatory options set. " \
           "Have a look at the README.rst to get information about the other available options and their meaning."
    click.echo(textwrap.fill(help, width))

    click.echo()
    nick = click.prompt("➤ Please enter your desired nick",
                        default=os.environ.get("USER", ""))
    twtfile = click.prompt(
        "➤ Please enter the desired location for your twtxt file",
        "~/twtxt.txt",
        type=click.Path())

    click.echo()
    add_news = click.confirm("➤ Do you want to follow the twtxt news feed?",
                             default=True)

    conf = Config(None)
    conf.create_config(nick, twtfile, add_news)
    open(os.path.expanduser(twtfile), 'a').close()

    click.echo()
    click.echo("✓ Created config file at '{}'.".format(
        click.format_filename(conf.config_file)))
Beispiel #3
0
def test_defaults():
    empty_cfg = configparser.ConfigParser()
    empty_conf = Config("foobar", empty_cfg)

    assert empty_conf.nick == os.environ.get("USER", "")
    assert empty_conf.twtfile == "twtxt.txt"
    assert empty_conf.twturl is None
    assert empty_conf.check_following is True
    assert empty_conf.use_pager is False
    assert empty_conf.porcelain is False
    assert empty_conf.limit_timeline == 20
    assert empty_conf.timeout == 5.0
    assert empty_conf.sorting == "descending"
    assert empty_conf.post_tweet_hook is None
Beispiel #4
0
def test_defaults():
    empty_cfg = configparser.ConfigParser()
    empty_conf = Config("foobar", empty_cfg)

    assert empty_conf.nick == os.environ.get("USER", "")
    assert empty_conf.twtfile == "twtxt.txt"
    assert empty_conf.twturl is None
    assert empty_conf.check_following is True
    assert empty_conf.use_pager is False
    assert empty_conf.use_cache is True
    assert empty_conf.porcelain is False
    assert empty_conf.character_limit is None
    assert empty_conf.character_warning is None
    assert empty_conf.disclose_identity is False
    assert empty_conf.limit_timeline == 20
    assert empty_conf.timeline_update_interval == 10
    assert empty_conf.timeout == 5.0
    assert empty_conf.sorting == "descending"
    assert empty_conf.post_tweet_hook is None
    assert empty_conf.pre_tweet_hook is None