Source code for mockslurm.mock_sinfo

#!/usr/bin/env python
"""Implements a mock of sinfo

This extremely minimal mock only prints hardcoded values corresponding to the
commands SAG uses in its tests in the SDE.
"""

import sys


[docs] def main(): sinfo_cmd = " ".join(sys.argv[1:]) match sinfo_cmd: case "-h -p test -N -o %N": print("localhost") case "-h -p test -N -T -o %N": print("slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost") case "-h -p test -T -o %N": print("slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost") case "-n -N -T -o %N": print( "RESV_NAME STATE START_TIME END_TIME DURATION NODELIST\n" "slurm_document ACTIVE 2024-04-18T15:20:03 2024-06-27T02:00:03 69-10:40:00 localhost" ) case _: raise ValueError( "Mock of sinfo only supports commands used in SAG tests, but got {}".format(" ".join(sys.argv)) )