-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_system.py
More file actions
38 lines (26 loc) · 1.41 KB
/
Copy pathtest_system.py
File metadata and controls
38 lines (26 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Tests for system specification detection."""
from unittest.mock import patch
from ollama_advisor import system
def test_usable_gb_cpu_only_uses_ram():
fake_mem = type("VM", (), {"total": 16 * 1024**3})()
with patch.object(system.psutil, "virtual_memory", return_value=fake_mem):
with patch.object(system, "_parse_nvidia_smi", return_value=None):
with patch.object(system, "_detect_apple_silicon_gpu", return_value=None):
specs = system.get_system_specs()
assert specs["gpu"]["type"] == "cpu"
assert specs["ram_gb"] == 16.0
assert specs["usable_gb"] == round(16.0 * system.USABLE_RATIO, 2)
def test_is_colab_false_without_module():
assert system.is_colab() is False
def test_nvidia_gpu_uses_vram_for_usable():
fake_mem = type("VM", (), {"total": 32 * 1024**3})()
gpu = {"type": "nvidia", "name": "Test GPU", "vram_gb": 8.0}
with patch.object(system.psutil, "virtual_memory", return_value=fake_mem):
with patch.object(system, "_parse_nvidia_smi", return_value=gpu):
specs = system.get_system_specs()
assert specs["gpu"]["type"] == "nvidia"
assert specs["usable_gb"] == round(8.0 * system.USABLE_RATIO, 2)
def test_platform_linux():
with patch.object(system, "is_colab", return_value=False):
with patch.object(system.platform, "system", return_value="Linux"):
assert system._detect_platform() == "linux"