Coverage for mockslurm/mock_sinfo.py: 86%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-04 23:38 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-04 23:38 +0000
1#!/usr/bin/env python
2"""Implements a mock of sinfo
4This extremely minimal mock only prints hardcoded values corresponding to the
5commands SAG uses in its tests in the SDE.
6"""
8import sys
11def main():
12 sinfo_cmd = " ".join(sys.argv[1:])
14 match sinfo_cmd:
15 case "-h -p test -N -o %N":
16 print("localhost")
17 case "-h -p test -N -T -o %N":
18 print("slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost")
19 case "-h -p test -T -o %N":
20 print("slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost")
21 case "-n -N -T -o %N":
22 print(
23 "RESV_NAME STATE START_TIME END_TIME DURATION NODELIST\n"
24 "slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost"
25 )
26 case _:
27 raise ValueError(
28 "Mock of sinfo only supports commands used in SAG tests, but got {}".format(" ".join(sys.argv))
29 )