def test_status_outside_vcs(): """Test calling 'perun status', without any wrapped repository Expecting ending with error, as we are not inside the perun repository """ with pytest.raises(NotPerunRepositoryException): commands.status()
def status(**kwargs): """Shows the status of vcs, associated profiles and perun. Shows the status of both the nearest perun and wrapped version control system. For vcs this outputs e.g. the current minor version ``HEAD``, current major version and description of the ``HEAD``. Moreover ``status`` prints the lists of tracked and pending (found in ``.perun/jobs``) profiles lexicographically sorted along with additional information such as their types and creation times. Unless ``perun --no-pager status`` is issued as command, or appropriate :ckey:`paging` option is set, the outputs of status will be paged (by default using ``less``. An error is raised if the command is executed outside of range of any perun, or configuration misses certain configuration keys (namely ``global.profile_info_fmt``). Refer to :ref:`logs-status` for information how to customize the outputs of ``status`` or how to set :ckey:`global.profile_info_fmt` in nearest configuration. """ try: commands.status(**kwargs) except (NotPerunRepositoryException, UnsupportedModuleException, MissingConfigSectionException) as exception: perun_log.error(str(exception))
def test_status_on_empty_repo(pcs_with_empty_git, capsys): """Test calling 'perun status', with wrapped repository without head""" with pytest.raises(SystemExit): commands.status() # Test that nothing is printed on out and something is printed on err out, err = capsys.readouterr() assert out == '' assert err != '' and 'fatal' in err
def test_status_no_pending(pcs_full, capsys, stored_profile_pool): """Test calling 'perun status', without pending profiles Expecting no error and long display of the current status of the perun, without any pending. """ commands.status() git_repo = git.Repo(pcs_full.vcs_path) out = capsys.readouterr()[0].split('\n') assert_info(out, git_repo, stored_profile_pool[1:], [])
def test_status_short_no_pending(pcs_full, capsys, stored_profile_pool): """Test calling 'perun status --short', without any pendding profiles Expecting no errors and short display of profiles. """ commands.status(short=True) # Assert the repo git_repo = git.Repo(pcs_full.vcs_path) raw_out, _ = capsys.readouterr() out = raw_out.split('\n') assert_short_info(out, git_repo, stored_profile_pool[1:], [])
def test_status_short(helpers, pcs_full, capsys, stored_profile_pool, valid_profile_pool): """Test calling 'perun status --short' with expected behaviour Expecting no errors and short display of the current status of the perun. """ helpers.populate_repo_with_untracked_profiles(pcs_full.path, valid_profile_pool) commands.status(**{'short': True}) # Assert the repo git_repo = git.Repo(pcs_full.vcs_path) raw_out, _ = capsys.readouterr() out = raw_out.split('\n') assert_short_info(out, git_repo, stored_profile_pool[1:], valid_profile_pool)
def test_status_no_profiles(pcs_full, capsys): """Test calling 'perun status', without any assigned profiles Expecting no error and long display of the current status of the perun, without any pending. """ # First we will do a new commit, with no profiles git_repo = git.Repo(pcs_full.vcs_path) file = os.path.join(os.getcwd(), 'file3') store.touch_file(file) git_repo.index.add([file]) git_repo.index.commit("new commit") commands.status() out = capsys.readouterr()[0].split('\n') assert_info(out, git_repo, [], [])
def test_status(helpers, pcs_full, capsys, stored_profile_pool, valid_profile_pool): """Test calling 'perun status' with expected behaviour Expecting no errors and long display of the current status of the perun, with all profiles. """ helpers.populate_repo_with_untracked_profiles(pcs_full.get_path(), valid_profile_pool) commands.status() git_repo = git.Repo(pcs_full.get_vcs_path()) raw_out, _ = capsys.readouterr() out = raw_out.split('\n') assert_info(out, git_repo, stored_profile_pool[1:], valid_profile_pool)
def test_status_short_no_profiles(pcs_full, capsys): """Test calling 'perun status --short', without any asigned profiles Expecting no errors and short display of status of the profiles """ # First we will do a new commit, with no profiles git_repo = git.Repo(pcs_full.vcs_path) file = os.path.join(os.getcwd(), 'file3') store.touch_file(file) git_repo.index.add([file]) git_repo.index.commit("new commit") commands.status(**{'short': True}) # Assert the repo out = capsys.readouterr()[0].split('\n') assert_short_info(out, git_repo, [], [])
def test_status_sort(monkeypatch, helpers, pcs_full, capsys, valid_profile_pool): """Test calling 'perun status' with expected behaviour TODO: Testing that the profiles are really sorted Expecting no errors and long display of the current status of the perun, with all profiles. """ helpers.populate_repo_with_untracked_profiles(pcs_full.get_path(), valid_profile_pool) decorators.remove_from_function_args_cache("lookup_key_recursively") # Try what happens if we screw the stored profile keys ;) cfg = config.Config( 'shared', '', { 'general': { 'paging': 'never' }, 'format': { 'status': '\u2503 %type% \u2503 %collector% \u2503 (%time%) \u2503 %source% \u2503' } }) monkeypatch.setattr("perun.logic.config.shared", lambda: cfg) commands.status() out, _ = capsys.readouterr() assert "missing set option" in out cfg = config.Config( 'shared', '', { 'general': { 'paging': 'never' }, 'format': { 'status': '\u2503 %type% \u2503 %collector% \u2503 (%time%) \u2503 %source% \u2503', 'sort_profiles_by': 'bogus' } }) monkeypatch.setattr("perun.logic.config.shared", lambda: cfg) commands.status() out, _ = capsys.readouterr() assert "invalid sort key" in out monkeypatch.undo()