Files
agent_platform_oci/tests/test_jev_endpoint.py

34 lines
1.4 KiB
Python

"""Offline regression tests: python -m unittest discover -s tests -p test_jev_endpoint.py"""
import importlib.util
import os
from pathlib import Path
import unittest
from unittest.mock import patch
CLIENT = Path(__file__).resolve().parents[1] / 'libs/agent_framework/src/agent_framework/decisions/client.py'
spec = importlib.util.spec_from_file_location('jev_client_patch', CLIENT)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
class EndpointTests(unittest.TestCase):
def test_default(self):
with patch.dict(os.environ, {}, clear=True):
self.assertEqual(module._jev_endpoint(), 'https://ai-gateway.vercel.sh/v1/decisions')
def test_typesafe_endpoint(self):
with patch.dict(os.environ, {'JEV_ENDPOINT': 'https://api.typesafe.ai/v1/systemone'}, clear=True):
self.assertEqual(module._jev_endpoint(), 'https://api.typesafe.ai/v1/systemone')
def test_reject_untrusted_host(self):
with patch.dict(os.environ, {'JEV_ENDPOINT': 'https://evil.example/v1/decisions'}, clear=True):
with self.assertRaises(ValueError):
module._jev_endpoint()
def test_reject_http(self):
with patch.dict(os.environ, {'JEV_ENDPOINT': 'http://api.typesafe.ai/v1/systemone'}, clear=True):
with self.assertRaises(ValueError):
module._jev_endpoint()
if __name__ == '__main__':
unittest.main()