Coverage for src/mockslurm/mock_sinfo.py: 82%
14 statements
« prev ^ index » next coverage.py v7.15.3, created at 2026-08-07 13:34 +0000
« prev ^ index » next coverage.py v7.15.3, created at 2026-08-07 13:34 +0000
1# Copyright 2026 CNRS
2# This software is distributed under the terms of the CeCILL-C free software license.
4"""Mock of sinfo.
6This extremely minimal mock only prints hardcoded values corresponding to the
7commands SAG uses in its tests in the SDE.
8"""
10import sys
13def main():
14 sinfo_cmd = " ".join(sys.argv[1:])
16 match sinfo_cmd:
17 case "-h -p test -N -o %N":
18 print("localhost")
19 case "-h -p test -N -T -o %N": 19 ↛ 20line 19 didn't jump to line 20 because the pattern on line 19 never matched
20 print("slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost")
21 case "-h -p test -T -o %N": 21 ↛ 22line 21 didn't jump to line 22 because the pattern on line 21 never matched
22 print("slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost")
23 case "-n -N -T -o %N":
24 print(
25 "RESV_NAME STATE START_TIME END_TIME DURATION NODELIST\n"
26 "slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost"
27 )
28 case _:
29 raise ValueError(
30 "Mock of sinfo only supports commands used in SAG tests, but got {}".format(" ".join(sys.argv))
31 )