Spaces:
Sleeping

studiq-backend / tests /test_exercise_eval.py
StudIQ Deploy Bot
Deploy from GitHub 336c411cba6a5f729ebdd4dba12a182faa91f51c
d6167ae
Raw History Blame Contribute Delete
479 Bytes
"""Unit tests for programming challenge test-case evaluation logic."""
import pytest
def test_exercise_testcase_scoring():
"""Verify test-case pass rate calculations."""
def calculate_score(passed: int, total: int, max_xp: int = 20) -> int:
if total == 0:
return 0
ratio = passed / total
return int(ratio * max_xp)
assert calculate_score(5, 5) == 20
assert calculate_score(2, 4) == 10
assert calculate_score(0, 5) == 0