from __future__ import annotations import argparse import sys import unittest from pathlib import Path PACKAGE_DIR = Path(__file__).resolve().parents[1] / "modelhub_submmit_api" if str(PACKAGE_DIR) in sys.path: sys.path.remove(str(PACKAGE_DIR)) sys.path.insert(0, str(PACKAGE_DIR)) from poll_runner import resolve_age_cleanup_policy # noqa: E402 class PollPolicyTests(unittest.TestCase): def test_age_cleanup_uses_eighty_once_then_ninety_five(self) -> None: args = argparse.Namespace( old_model_queue_threshold=80, dynamic_old_model_cleanup_threshold=95, ) self.assertEqual( ("initial", 80), resolve_age_cleanup_policy(args, initial_cleanup_pending=True), ) self.assertEqual( ("dynamic", 95), resolve_age_cleanup_policy(args, initial_cleanup_pending=False), ) def test_dynamic_cleanup_cannot_be_stricter_than_admission(self) -> None: args = argparse.Namespace( old_model_queue_threshold=80, dynamic_old_model_cleanup_threshold=70, ) self.assertEqual( ("dynamic", 80), resolve_age_cleanup_policy(args, initial_cleanup_pending=False), ) if __name__ == "__main__": unittest.main()