Пример #1
0
def test_virtual_env_segment_text_is_empty_when_deactivated():
    os.unsetenv('VIRTUAL_ENV')
    if 'VIRTUAL_ENV' in os.environ:  # when running tests in a virtualenv
        del os.environ['VIRTUAL_ENV']
    colors.load_theme()

    assert virtual_env.segment() == {'text': '', 'style': colors.style('mute')}
Пример #2
0
def test_current_working_path_segment_contains_text_and_style():
    colors.load_theme()
    os.chdir(str(Path('/tmp')))

    segment = current_working_path.segment()

    assert segment == {'text': '/tmp', 'style': colors.style('info')}
Пример #3
0
def test_virtual_env_segment_text_is_empty_when_activated():
    os.environ['VIRTUAL_ENV'] = '/path/to/virtual/env'
    colors.load_theme()

    assert virtual_env.segment() == {
        'text': 'env',
        'style': colors.style('mute')
    }
Пример #4
0
def test_repository_active_branch_segment_contains_text_and_style():
    colors.load_theme()

    with tempfile.TemporaryDirectory() as tmp_repo:
        empty_repo = git.Repo.init(tmp_repo)
        segment = repository.ActiveBranch(tmp_repo).segment()

        assert segment == {'text': 'master', 'style': colors.style('mute')}
Пример #5
0
def test_repository_is_dirty_segment_contains_text_and_style():
    colors.load_theme()

    with tempfile.TemporaryDirectory() as tmp_repo:
        empty_repo = git.Repo.init(tmp_repo)
        new_file = tempfile.NamedTemporaryFile(dir=tmp_repo)

        segment = repository.IsDirty(tmp_repo).segment()
        assert segment == {'text': '*', 'style': colors.style('mute')}

        new_file.close()
Пример #6
0
 def segment(self):
     return {
         'text': self.raw(),
         'style': colors.style('mute')
     }
Пример #7
0
def segment():
    return {'text': raw(), 'style': colors.style('info')}
Пример #8
0
def style(last_command_status):
    return colors.style(
        'primary'
    ) if last_command_status == constants.SUCCESS else colors.style('danger')
Пример #9
0
def test_prompt_symbol_segment_contains_text_and_style():
    colors.load_theme()
    segment = prompt_symbol.segment()

    assert segment == {'text': '❯', 'style': colors.style('primary')}
Пример #10
0
def test_prompt_symbol_segment_contains_text_and_danger_color_when_last_command_failed(
):
    colors.load_theme()
    segment = prompt_symbol.segment(last_command_status=constants.FAIL)

    assert segment == {'text': '❯', 'style': colors.style('danger')}
Пример #11
0
def test_prompt_symbol_style_is_danger_color_when_last_command_failed():
    assert prompt_symbol.style(
        last_command_status=constants.FAIL) == colors.style('danger')
Пример #12
0
def test_prompt_symbol_segment_contains_text_and_primary_color_when_last_command_succeed(
):
    colors.load_theme()
    segment = prompt_symbol.segment(last_command_status=constants.SUCCESS)

    assert segment == {'text': '❯', 'style': colors.style('primary')}
Пример #13
0
def test_prompt_symbol_style_is_primary_color_when_last_command_succeed():
    assert prompt_symbol.style(
        last_command_status=constants.SUCCESS) == colors.style('primary')