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')}
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')}
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') }
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')}
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()
def segment(self): return { 'text': self.raw(), 'style': colors.style('mute') }
def segment(): return {'text': raw(), 'style': colors.style('info')}
def style(last_command_status): return colors.style( 'primary' ) if last_command_status == constants.SUCCESS else colors.style('danger')
def test_prompt_symbol_segment_contains_text_and_style(): colors.load_theme() segment = prompt_symbol.segment() assert segment == {'text': '❯', 'style': colors.style('primary')}
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')}
def test_prompt_symbol_style_is_danger_color_when_last_command_failed(): assert prompt_symbol.style( last_command_status=constants.FAIL) == colors.style('danger')
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')}
def test_prompt_symbol_style_is_primary_color_when_last_command_succeed(): assert prompt_symbol.style( last_command_status=constants.SUCCESS) == colors.style('primary')