Skip to content

Commit a1208c6

Browse files
test: improve coverage for jobinfo
1 parent 63de9f4 commit a1208c6

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/test_jobinfo.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
import argparse
22
import pytest
33

4-
from ccbr_tools.jobinfo import get_jobinfo
4+
from ccbr_tools.shell import shell_run
5+
from ccbr_tools.jobinfo import get_jobinfo, check_host, mem2gb, time2sec
6+
7+
8+
def test_jobinfo_cli():
9+
out = shell_run("python -m ccbr_tools.jobinfo -j 123456")
10+
assert "This script only works on BIOWULF!" in out
511

612

713
def test_jobinfo():
814
with pytest.raises(SystemExit) as exc_info:
915
get_jobinfo(argparse.Namespace(joblist=["job1", "job2"]))
1016
assert str(exc_info.value) == "" and type(exc_info.value) is SystemExit
17+
18+
19+
def test_check_host():
20+
with pytest.raises(SystemExit) as exc_info:
21+
check_host()
22+
assert str(exc_info.value) == "" and type(exc_info.value) is SystemExit
23+
24+
25+
def test_mem2gb():
26+
assert all(
27+
[
28+
mem2gb("0") == 0.0,
29+
mem2gb("3.5 GB") == 3.5,
30+
mem2gb("1024 MB") == 1.0,
31+
mem2gb("1048576 KB") == 1.0,
32+
]
33+
)
34+
35+
36+
def test_time2sec():
37+
assert time2sec("0-00:01:00") == 60.0

0 commit comments

Comments
 (0)