From 95701c0440559edeeb73481597b6612dc88a8aed Mon Sep 17 00:00:00 2001 From: Troy Comi Date: Thu, 17 Mar 2022 13:29:26 -0400 Subject: [PATCH] Full coverage --- pyproject.toml | 2 +- tests/test_reportseff.py | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 615b782..c4cb078 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "reportseff" -version = "2.1.0" +version = "2.1.1" description= "Tablular seff output" authors = ["Troy Comi "] license = "MIT" diff --git a/tests/test_reportseff.py b/tests/test_reportseff.py index 36476f4..2855831 100644 --- a/tests/test_reportseff.py +++ b/tests/test_reportseff.py @@ -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)