Add 3_cost_scaling_analysis/tests/test_core.py
This commit is contained in:
parent
8f4dd6b9d3
commit
bd0c7e098c
1 changed files with 40 additions and 0 deletions
40
3_cost_scaling_analysis/tests/test_core.py
Normal file
40
3_cost_scaling_analysis/tests/test_core.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
import pytest
|
||||||
|
import math
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
# Da der getestete Modulpfad nicht explizit angegeben ist, nehmen wir das Package an
|
||||||
|
from src.cost_scaling_analysis.core import analyze_cost_scalability
|
||||||
|
|
||||||
|
class TestAnalyzeCostScalability:
|
||||||
|
def test_nominal_values(self):
|
||||||
|
# Nominaler Fall mit typischen Worker-Werten
|
||||||
|
result = analyze_cost_scalability(10)
|
||||||
|
assert isinstance(result, float), 'Return type muss float sein'
|
||||||
|
assert result >= 0.0, 'Kosten sollten nicht negativ sein'
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('worker_count', [1, 5, 20, 50])
|
||||||
|
def test_scaling_behavior(self, worker_count):
|
||||||
|
base = analyze_cost_scalability(worker_count)
|
||||||
|
assert math.isfinite(base), 'Ergebnis muss endlich sein'
|
||||||
|
# Bei mehr Workern sollte Gesamt-Kostenmetrik typischerweise steigen oder saturieren
|
||||||
|
if worker_count > 1:
|
||||||
|
smaller = analyze_cost_scalability(worker_count - 1)
|
||||||
|
assert base >= smaller or math.isclose(base, smaller, rel_tol=1e-3)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('worker_count', [0, -1, -10])
|
||||||
|
def test_invalid_worker_inputs(self, worker_count):
|
||||||
|
# Negative oder null-Anzahl sollte Fehler auslösen
|
||||||
|
with pytest.raises((ValueError, AssertionError, TypeError)):
|
||||||
|
_ = analyze_cost_scalability(worker_count)
|
||||||
|
|
||||||
|
def test_extreme_high_value(self):
|
||||||
|
# Test mit großem Wert zur Überprüfung von Skalierungsgrenzen
|
||||||
|
result = analyze_cost_scalability(10_000)
|
||||||
|
assert isinstance(result, float)
|
||||||
|
assert result > 0.0, 'Wert sollte bei vielen Workern steigen'
|
||||||
|
|
||||||
|
def test_consistency_multiple_calls(self):
|
||||||
|
# Wiederholte Aufrufe mit gleichem Input
|
||||||
|
val1 = analyze_cost_scalability(8)
|
||||||
|
val2 = analyze_cost_scalability(8)
|
||||||
|
assert math.isclose(val1, val2, rel_tol=1e-9), 'Funktion sollte deterministisch sein'
|
||||||
Loading…
Reference in a new issue