"""Test resources module.""" from glicid_spawner.resources import CPU, GPU_DEFAULTS, MEMORY, get_folders, gpu_max_duration def test_default_resources(): """Test default resources duration default allocations.""" assert list(CPU) == [1, 2, 4, 8, 12, 24] assert list(CPU.values()) == [24, 12, 6, 3, 2, 1] assert list(MEMORY) == [4, 8, 16, 32, 48, 96] assert list(MEMORY.values()) == [24, 12, 6, 3, 2, 1] assert list(GPU_DEFAULTS) == ['None', 'A40', 'A100'] assert list(GPU_DEFAULTS.values()) == [24, 2, 1] def test_gpu_max_duration(): """Test GPU max duration allocation.""" gpu = gpu_max_duration(['T4', 'A100', 'None', 'K80', 'A100', 'T4'], unknown_default=3) # Sorted by defaults order, then unknowns assert list(gpu) == ['None', 'A100', 'T4', 'K80'] assert list(gpu.values()) == [24, 1, 3, 3] def test_resources_workdir(): """Test resources working directories.""" assert get_folders('john-doe') == [ '/home/john-doe', '/scratch/nautilus/users/john-doe', '/scratch/waves/users/john-doe', '/scratch/nautilus/projects', '/scratch/waves/projects', '/LAB-DATA/', ]