34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from domainCheck.detect import aizhan, baidu, c360, chinaz
|
|
|
|
|
|
class StepTimeoutBudgetTests(unittest.TestCase):
|
|
def test_baidu_timeout_respects_remaining_budget(self):
|
|
with patch.dict("os.environ", {}, clear=False):
|
|
timeout = baidu._resolve_baidu_timeout({"http": "http://127.0.0.1:8080"}, budget_seconds=1.1)
|
|
self.assertLessEqual(timeout, 1.1)
|
|
self.assertGreaterEqual(timeout, 0.6)
|
|
|
|
def test_360_timeout_respects_remaining_budget(self):
|
|
with patch.dict("os.environ", {}, clear=False):
|
|
timeout = c360._resolve_360_timeout({"http": "http://127.0.0.1:8080"}, budget_seconds=0.9)
|
|
self.assertLessEqual(timeout, 0.9)
|
|
self.assertGreaterEqual(timeout, 0.6)
|
|
|
|
def test_chinaz_timeout_respects_remaining_budget(self):
|
|
timeout = chinaz._resolve_chinaz_timeout({"http": "http://127.0.0.1:8080"}, budget_seconds=1.3)
|
|
self.assertLessEqual(timeout, 1.3)
|
|
self.assertGreaterEqual(timeout, 0.6)
|
|
|
|
def test_aizhan_timeout_respects_remaining_budget(self):
|
|
with patch.dict("os.environ", {}, clear=False):
|
|
timeout = aizhan._resolve_aizhan_timeout({"http": "http://127.0.0.1:8080"}, budget_seconds=1.0)
|
|
self.assertLessEqual(timeout, 1.0)
|
|
self.assertGreaterEqual(timeout, 0.6)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|