Esempio n. 1
0
def test_config_with_topics_list_passes():
    # GIVEN a path to a config file with topics
    # WHEN it is loaded
    # THEN the config object should contain those topics
    config_path = CONFIG_FIXTURES_DIR / 'valid_config.yml'
    config = dot.get_config(config_path)
    assert [Topic(name='python'), Topic(name='homebrew')] == config.topics
Esempio n. 2
0
def topics_multi_states():
    """Several topics with mix of enabled & disabled states."""
    return (
        # Enabled topics
        Topic(name='homebrew', enabled=True),
        Topic(name='python', enabled=True),
        # Disabled topics
        Topic(name='ruby', enabled=False),
        Topic(name='zsh', enabled=False),
    )
Esempio n. 3
0
def test_list_disabled_topics(config_with_topics: DotfileConfig):
    # GIVEN a config object
    # WHEN disabled topics are listed
    # THEN enabled topics should be filtered out
    expected_topics = [
        Topic('ruby', False),
        Topic('zsh', False),
    ]
    topics = dot.list_topics(config_with_topics, enabled=False)

    assert expected_topics == topics
Esempio n. 4
0
def test_list_enabled_topics(config_with_topics: DotfileConfig):
    # GIVEN a config object
    # WHEN enabled topics are listed
    # THEN disabled topics should be filtered out
    expected_topics = [
        Topic('homebrew', True),
        Topic('python', True),
    ]
    topics = dot.list_topics(config_with_topics, enabled=True)

    assert expected_topics == topics
Esempio n. 5
0
def test_list_all_topics(config_with_topics: DotfileConfig):
    # GIVEN a config object
    # WHEN all topics are listed
    # THEN no topics should be filtered out
    expected_topics = [
        Topic('homebrew', True),
        Topic('python', True),
        Topic('ruby', False),
        Topic('zsh', False),
    ]
    topics = dot.list_topics(config_with_topics)

    assert expected_topics == topics
Esempio n. 6
0
def test_defaults():
    """Using no parameters should invoke defaults."""
    expected_topic = Topic(
        name='',
        enabled=True,
        symlinks=[],
        installer='install.zsh',
        aliaser='aliases.zsh',
        pather='paths.zsh',
        enver='envs.zsh',
    )
    actual_topic = Topic()

    assert expected_topic == actual_topic
Esempio n. 7
0
def ruby_topic(topics_dir: Path) -> Topic:
    """Creates a ruby Topic that is DISABLED."""
    ruby_topic_dir = topics_dir / 'ruby'
    return Topic(
        name='ruby',
        enabled=False,
        symlinks=[ruby_topic_dir / 'ruby.symlink'],
        installer=ruby_topic_dir / 'init.zsh',
        # Doesn't specify `aliaser`, `pather`, or `enver`
    )
Esempio n. 8
0
def python_topic(topics_dir: Path) -> Topic:
    """Creates a python Topic that is ENABLED & has all attributes set."""
    python_topic_dir = topics_dir / 'python'
    return Topic(
        name='python',
        enabled=True,
        symlinks=[python_topic_dir / 'python.symlink'],
        installer=python_topic_dir / 'init.zsh',
        aliaser=python_topic_dir / 'aliases.zsh',
        pather=python_topic_dir / 'path.zsh',
        enver=python_topic_dir / 'env.zsh',
    )
def enabled_topic(topics_dir: Path) -> Topic:
    topic = Topic(
        name='python',
        enabled=True,
        symlinks=[
            Path(topics_dir, 'python', 'python.symlink'),
            Path(topics_dir, 'python', 'python.py.symlink'),
            Path(topics_dir, 'python', 'sub1/python_path.symlink'),
        ],
    )

    create_structure_for_topic(topics_dir, topic)

    return topic
Esempio n. 10
0
def zsh_topic(topics_dir: Path) -> Topic:
    """Creates a zsh Topic that is ENABLED & does not set the
    `pather` and `enver` attributes.
    """
    zsh_topic_dir = topics_dir / 'zsh'
    return Topic(
        name='zsh',
        enabled=True,
        symlinks=[zsh_topic_dir / 'zshrc.symlink'],
        installer=zsh_topic_dir /
        'install.zsh',  # Change from default 'init.zsh'
        aliaser=zsh_topic_dir / 'aliases.zsh',
        # Doesn't specify `pather` or `enver`
    )
Esempio n. 11
0

@pytest.fixture()
def topic_config_no_enabled(topic_config_default: dict) -> dict:
    config = topic_config_default.copy()
    if 'enabled' in config:
        del config['enabled']
    yield config


@pytest.mark.parametrize('topic_config, expected_topic', [
    param(
        {'name': 'python'},
        Topic('python',
              enabled=True,
              installer='install.zsh',
              aliaser='aliases.zsh',
              pather='paths.zsh',
              enver='envs.zsh'),
        id='defaults',
    ),
    param(
        {
            'name': 'python',
            'enabled': False
        },
        Topic('python', enabled=False),
        id='enabled',
    ),
    param(
        {
            'name': 'python',