mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-27 06:01:01 +02:00
Some tests broken
This commit is contained in:
parent
1e3bfe5a15
commit
c2d0d22549
2 changed files with 20 additions and 19 deletions
|
|
@ -11,14 +11,6 @@ from trustgraph.base.flow_processor import FlowProcessor
|
||||||
from trustgraph.base import ParameterSpec, ConsumerSpec, ProducerSpec
|
from trustgraph.base import ParameterSpec, ConsumerSpec, ProducerSpec
|
||||||
|
|
||||||
|
|
||||||
def mock_async_processor_init(self, **params):
|
|
||||||
"""Mock AsyncProcessor.__init__ that properly initializes required attributes"""
|
|
||||||
self.config_handlers = []
|
|
||||||
self.id = params.get('id', 'test-service')
|
|
||||||
|
|
||||||
|
|
||||||
# Apply the mock globally for this test module
|
|
||||||
patch('trustgraph.base.async_processor.AsyncProcessor.__init__', mock_async_processor_init).start()
|
|
||||||
|
|
||||||
|
|
||||||
class TestFlowParameterSpecs(IsolatedAsyncioTestCase):
|
class TestFlowParameterSpecs(IsolatedAsyncioTestCase):
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,22 @@ from trustgraph.base import ParameterSpec, ConsumerSpec, ProducerSpec
|
||||||
from trustgraph.schema import TextCompletionRequest, TextCompletionResponse
|
from trustgraph.schema import TextCompletionRequest, TextCompletionResponse
|
||||||
|
|
||||||
|
|
||||||
def mock_async_processor_init(self, **params):
|
|
||||||
"""Mock AsyncProcessor.__init__ that properly initializes required attributes"""
|
|
||||||
self.config_handlers = []
|
|
||||||
self.id = params.get('id', 'test-service')
|
|
||||||
|
|
||||||
|
|
||||||
# Apply the mock globally for this test module
|
|
||||||
patch('trustgraph.base.async_processor.AsyncProcessor.__init__', mock_async_processor_init).start()
|
|
||||||
|
|
||||||
|
|
||||||
class TestLlmServiceParameters(IsolatedAsyncioTestCase):
|
class TestLlmServiceParameters(IsolatedAsyncioTestCase):
|
||||||
"""Test LLM service parameter specification functionality"""
|
"""Test LLM service parameter specification functionality"""
|
||||||
|
|
||||||
def test_parameter_specs_registration(self):
|
@patch('trustgraph.base.async_processor.AsyncProcessor.__init__')
|
||||||
|
def test_parameter_specs_registration(self, mock_async_init):
|
||||||
"""Test that LLM service registers model and temperature parameter specs"""
|
"""Test that LLM service registers model and temperature parameter specs"""
|
||||||
|
# Mock AsyncProcessor.__init__ to set required attributes
|
||||||
|
def mock_init(self, **params):
|
||||||
|
self.config_handlers = []
|
||||||
|
self.id = params.get('id', 'test-service')
|
||||||
|
self.specifications = []
|
||||||
|
|
||||||
|
mock_async_init.side_effect = mock_init
|
||||||
|
|
||||||
# Arrange
|
# Arrange
|
||||||
config = {
|
config = {
|
||||||
'id': 'test-llm-service',
|
'id': 'test-llm-service',
|
||||||
|
|
@ -44,7 +45,8 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase):
|
||||||
assert "temperature" in param_specs
|
assert "temperature" in param_specs
|
||||||
assert len(param_specs) >= 2 # May have other parameter specs
|
assert len(param_specs) >= 2 # May have other parameter specs
|
||||||
|
|
||||||
def test_model_parameter_spec_properties(self):
|
@patch('trustgraph.base.async_processor.AsyncProcessor.__init__', return_value=None)
|
||||||
|
def test_model_parameter_spec_properties(self, mock_async_init):
|
||||||
"""Test that model parameter spec has correct properties"""
|
"""Test that model parameter spec has correct properties"""
|
||||||
# Arrange
|
# Arrange
|
||||||
config = {
|
config = {
|
||||||
|
|
@ -54,6 +56,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
service = LlmService(**config)
|
service = LlmService(**config)
|
||||||
|
# Manually set required attributes that would be set by AsyncProcessor
|
||||||
|
service.config_handlers = []
|
||||||
|
service.id = config['id']
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
model_spec = None
|
model_spec = None
|
||||||
|
|
@ -65,7 +70,8 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase):
|
||||||
assert model_spec is not None
|
assert model_spec is not None
|
||||||
assert model_spec.name == "model"
|
assert model_spec.name == "model"
|
||||||
|
|
||||||
def test_temperature_parameter_spec_properties(self):
|
@patch('trustgraph.base.async_processor.AsyncProcessor.__init__', return_value=None)
|
||||||
|
def test_temperature_parameter_spec_properties(self, mock_async_init):
|
||||||
"""Test that temperature parameter spec has correct properties"""
|
"""Test that temperature parameter spec has correct properties"""
|
||||||
# Arrange
|
# Arrange
|
||||||
config = {
|
config = {
|
||||||
|
|
@ -75,6 +81,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
service = LlmService(**config)
|
service = LlmService(**config)
|
||||||
|
# Manually set required attributes that would be set by AsyncProcessor
|
||||||
|
service.config_handlers = []
|
||||||
|
service.id = config['id']
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
temperature_spec = None
|
temperature_spec = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue