Coverage for mockslurm/mock_sinfo.py: 82%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-21 00:38 +0000

1#!/usr/bin/env python 

2"""Implements a mock of sinfo 

3 

4This extremely minimal mock only prints hardcoded values corresponding to the 

5commands SAG uses in its tests in the SDE. 

6""" 

7 

8import sys 

9 

10 

11def main(): 

12 sinfo_cmd = " ".join(sys.argv[1:]) 

13 

14 match sinfo_cmd: 

15 case "-h -p test -N -o %N": 

16 print("localhost") 

17 case "-h -p test -N -T -o %N": 17 ↛ 18line 17 didn't jump to line 18 because the pattern on line 17 never matched

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": 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 "-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 )