Skip to content

Commit

Permalink
test: improve coverage for jobinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Dec 31, 2024
1 parent 63de9f4 commit a1208c6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/test_jobinfo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
import argparse
import pytest

from ccbr_tools.jobinfo import get_jobinfo
from ccbr_tools.shell import shell_run
from ccbr_tools.jobinfo import get_jobinfo, check_host, mem2gb, time2sec


def test_jobinfo_cli():
out = shell_run("python -m ccbr_tools.jobinfo -j 123456")
assert "This script only works on BIOWULF!" in out


def test_jobinfo():
with pytest.raises(SystemExit) as exc_info:
get_jobinfo(argparse.Namespace(joblist=["job1", "job2"]))
assert str(exc_info.value) == "" and type(exc_info.value) is SystemExit


def test_check_host():
with pytest.raises(SystemExit) as exc_info:
check_host()
assert str(exc_info.value) == "" and type(exc_info.value) is SystemExit


def test_mem2gb():
assert all(
[
mem2gb("0") == 0.0,
mem2gb("3.5 GB") == 3.5,
mem2gb("1024 MB") == 1.0,
mem2gb("1048576 KB") == 1.0,
]
)


def test_time2sec():
assert time2sec("0-00:01:00") == 60.0

0 comments on commit a1208c6

Please sign in to comment.