Add artifact_3_retry_tail_analysis/tests/test_core.py
This commit is contained in:
parent
fb1d6cc370
commit
87b1915f34
1 changed files with 49 additions and 0 deletions
49
artifact_3_retry_tail_analysis/tests/test_core.py
Normal file
49
artifact_3_retry_tail_analysis/tests/test_core.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import pytest
|
||||
from artifact_3_retry_tail_analysis import core
|
||||
|
||||
|
||||
def test_analyze_retry_tails_basic_case():
|
||||
data_enforced = {"retry_tail_p99": 120.0}
|
||||
data_randomized = {"retry_tail_p99": 150.0}
|
||||
|
||||
result = core.analyze_retry_tails(data_enforced, data_randomized)
|
||||
|
||||
assert isinstance(result, dict)
|
||||
assert "retry_tail_p99" in result
|
||||
assert "difference" in result
|
||||
assert result["retry_tail_p99"] == 120.0
|
||||
assert pytest.approx(result["difference"]) == -30.0
|
||||
|
||||
|
||||
def test_analyze_retry_tails_swapped_values():
|
||||
data_enforced = {"retry_tail_p99": 200.0}
|
||||
data_randomized = {"retry_tail_p99": 100.0}
|
||||
|
||||
result = core.analyze_retry_tails(data_enforced, data_randomized)
|
||||
|
||||
assert pytest.approx(result["difference"]) == 100.0
|
||||
assert result["retry_tail_p99"] == 200.0
|
||||
|
||||
|
||||
def test_analyze_retry_tails_input_validation():
|
||||
# Missing required field
|
||||
with pytest.raises((KeyError, ValueError, AssertionError)):
|
||||
core.analyze_retry_tails({}, {"retry_tail_p99": 10.0})
|
||||
|
||||
# Invalid data type
|
||||
with pytest.raises((TypeError, AssertionError)):
|
||||
core.analyze_retry_tails({"retry_tail_p99": "not_a_number"}, {"retry_tail_p99": 10.0})
|
||||
|
||||
|
||||
def test_analyze_retry_tails_edges():
|
||||
# Equal values => difference = 0.0
|
||||
data_enforced = {"retry_tail_p99": 100.0}
|
||||
data_randomized = {"retry_tail_p99": 100.0}
|
||||
result = core.analyze_retry_tails(data_enforced, data_randomized)
|
||||
assert pytest.approx(result["difference"]) == 0.0
|
||||
|
||||
# Negative values (simulated edge)
|
||||
data_enforced = {"retry_tail_p99": -50.0}
|
||||
data_randomized = {"retry_tail_p99": -30.0}
|
||||
result = core.analyze_retry_tails(data_enforced, data_randomized)
|
||||
assert pytest.approx(result["difference"]) == -20.0
|
||||
Loading…
Reference in a new issue