Skip to content

Commit

Permalink
Full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
troycomi committed Mar 17, 2022
1 parent 481ac08 commit 95701c0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "reportseff"
version = "2.1.0"
version = "2.1.1"
description= "Tablular seff output"
authors = ["Troy Comi <[email protected]>"]
license = "MIT"
Expand Down
48 changes: 48 additions & 0 deletions tests/test_reportseff.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,54 @@ def test_since(mocker, mock_inquirer):
assert output[1].split() == ["25569410", "COMPLETED", "21:14:48", "91.7%", "1.6%"]


def test_since_all_users(mocker, mock_inquirer):
"""Can limit outputs by time since argument."""
mocker.patch("reportseff.console.which", return_value=True)
runner = CliRunner()
sub_result = mocker.MagicMock()
sub_result.returncode = 0
sub_result.stdout = (
"|1|01:27:42|24418435|24418435||1|1Gn|"
"COMPLETED|01:27:29\n"
"|1|01:27:42|24418435.batch|24418435.batch|499092K|1|1Gn|"
"COMPLETED|01:27:29\n"
"|1|01:27:42|24418435.extern|24418435.extern|1376K|1|1Gn|"
"COMPLETED|00:00:00\n"
"|1|21:14:48|25569410|25569410||1|4000Mc|COMPLETED|19:28:36\n"
"|1|21:14:49|25569410.extern|25569410.extern|1548K|1|4000Mc|"
"COMPLETED|00:00:00\n"
"|1|21:14:43|25569410.0|25569410.0|62328K|1|4000Mc|COMPLETED|19:28:36\n"
)
mock_sub = mocker.patch(
"reportseff.db_inquirer.subprocess.run", return_value=sub_result
)
result = runner.invoke(
console.main,
"--no-color --since 200406 " "--format JobID%>,State,Elapsed%>,CPUEff,MemEff",
)

assert result.exit_code == 0
# remove header
output = result.output.split("\n")[1:]
assert output[0].split() == ["24418435", "COMPLETED", "01:27:42", "99.8%", "47.7%"]
assert output[1].split() == ["25569410", "COMPLETED", "21:14:48", "91.7%", "1.6%"]

mock_sub.assert_called_once_with(
args=(
"sacct -P -n "
"--format=AdminComment,AllocCPUS,Elapsed,JobID,JobIDRaw,"
"MaxRSS,NNodes,REQMEM,State,TotalCPU "
"--allusers " # all users is added since no jobs/files were specified
"--starttime=200406"
).split(),
capture_output=True,
encoding=mocker.ANY,
check=mocker.ANY,
text=True,
shell=False,
)


def test_simple_state(mocker, mock_inquirer):
"""Can limit outputs by filtering state."""
mocker.patch("reportseff.console.which", return_value=True)
Expand Down

0 comments on commit 95701c0

Please sign in to comment.