haystack/test/prompt/conftest.py
Silvano Cerza c3abf73332
refactor: Rework prompt tests (#4600)
* Rework some PromptNode and PromptModel tests

* Remove duplicate code in PromptNode

* Fix mypy

* Fix test cause of missing fixture

* Revert "Fix mypy"

This reverts commit e530295a06cb260d9a8bd89679534958cb3d9776.

* Revert "Remove duplicate code in PromptNode"

This reverts commit 4a678ae81504dcc78a737372c061d12dc8799639.
2023-04-06 14:47:44 +02:00

13 lines
429 B
Python

from unittest.mock import Mock
def create_mock_layer_that_supports(model_name, response=["fake_response"]):
"""
Create a mock invocation layer that supports the model_name and returns response.
"""
def mock_supports(model_name_or_path, **kwargs):
return model_name_or_path == model_name
return Mock(**{"model_name_or_path": model_name, "supports": mock_supports, "invoke.return_value": response})