pytest_agentic_fabric.mocking¶
Mocking helpers for tests that exercise agentic-fabric integrations.
Module Contents¶
Classes¶
Convenience wrapper around pytest-mock for optional agent runtime tests. |
Functions¶
Provide |
|
Provide the concise |
|
Mock every optional agent runtime framework. |
|
Mock CrewAI modules only. |
|
Mock LangGraph modules only. |
|
Mock Strands modules only. |
Data¶
API¶
- pytest_agentic_fabric.mocking.CREWAI_MODULES: tuple[str, ...] = ('crewai', 'crewai.knowledge', 'crewai.knowledge.source', 'crewai.knowledge.source.text_file_knowled...¶
- pytest_agentic_fabric.mocking.LANGGRAPH_MODULES: tuple[str, ...] = ('langgraph', 'langgraph.prebuilt', 'langchain_anthropic')¶
- pytest_agentic_fabric.mocking.STRANDS_MODULES: tuple[str, ...] = ('strands',)¶
- pytest_agentic_fabric.mocking.RUNTIME_MODULES: dict[str, tuple[str, ...]] = None¶
- pytest_agentic_fabric.mocking.ALL_FRAMEWORK_MODULES: tuple[str, ...] = ()¶
- class pytest_agentic_fabric.mocking.FabricMocker¶
Convenience wrapper around pytest-mock for optional agent runtime tests.
- mocker: pytest_mock.MockerFixture = None¶
- mocked_modules: dict[str, types.ModuleType] = 'field(...)'¶
- property MagicMock: Any¶
Return
mocker.MagicMockfor direct test customization.
- property Mock: Any¶
Return
mocker.Mockfor direct test customization.
- property patch: Any¶
Return
mocker.patchfor direct test customization.
- property spy: Any¶
Return
mocker.spyfor direct test customization.
- property stub: Any¶
Return
mocker.stubfor direct test customization.
- mock_module(module_name: str) types.ModuleType¶
Install one fake import module and return it.
- mock_modules(module_names: collections.abc.Iterable[str]) dict[str, types.ModuleType]¶
Install multiple fake import modules.
- restore_modules() None¶
Restore fake modules and parent module attributes.
- mock_crewai() dict[str, types.ModuleType]¶
Install fake CrewAI modules with common entry points.
- mock_crewai_agent(**kwargs: Any) Any¶
Create a standalone CrewAI agent mock.
- mock_crewai_task(**kwargs: Any) Any¶
Create a standalone CrewAI task mock.
- mock_crewai_crew(result: str = 'Test result', **kwargs: Any) Any¶
Create a CrewAI crew mock whose
kickoffreturns a raw result.
- patch_crewai_agent() Any¶
Patch
crewai.Agentand return the patch mock.
- patch_crewai_task() Any¶
Patch
crewai.Taskand return the patch mock.
- patch_crewai_crew() Any¶
Patch
crewai.Crewand return the patch mock.
- patch_crewai_process() Any¶
Patch
crewai.Processand return the patch mock.
- patch_knowledge_source() Any¶
Patch or return the CrewAI text-file knowledge source mock.
- mock_langgraph() dict[str, types.ModuleType]¶
Install fake LangGraph modules with common entry points.
- patch_create_react_agent() Any¶
Patch or return
langgraph.prebuilt.create_react_agent.
- patch_chat_anthropic() Any¶
Patch or return
langchain_anthropic.ChatAnthropic.
- mock_langgraph_graph(result: str = 'Test response') Any¶
Create a LangGraph graph mock whose
invokereturns one message.
- mock_strands() dict[str, types.ModuleType]¶
Install fake Strands modules with common entry points.
- patch_strands_agent() Any¶
Patch or return
strands.Agent.
- mock_strands_agent(result: str = 'Test response') Any¶
Create a Strands agent mock whose call returns text.
- mock_all_frameworks() dict[str, types.ModuleType]¶
Install all supported optional runtime modules.
- patch_get_llm(return_value: Any = None) Any¶
Patch
agentic_fabric.config.llm.get_llm.
- patch_discover_packages(packages: dict[str, Any] | None = None) Any¶
Patch
agentic_fabric.core.discovery.discover_packages.
- patch_get_fabric_agent_config(config: dict[str, Any] | None = None) Any¶
Patch
agentic_fabric.core.discovery.get_fabric_agent_config.
- patch_run_fabric_agent_auto(result: str = 'Test result') Any¶
Patch
agentic_fabric.core.decomposer.run_fabric_agent_auto.
- pytest_agentic_fabric.mocking.agentic_fabric_mocker(mocker: pytest_mock.MockerFixture) collections.abc.Generator[pytest_agentic_fabric.mocking.FabricMocker, None, None]¶
Provide
FabricMockerfor agentic-fabric tests.
- pytest_agentic_fabric.mocking.fabric_mocker(mocker: pytest_mock.MockerFixture) collections.abc.Generator[pytest_agentic_fabric.mocking.FabricMocker, None, None]¶
Provide the concise
FabricMockerfixture name.
- pytest_agentic_fabric.mocking.mock_agentic_frameworks(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]¶
Mock every optional agent runtime framework.
- pytest_agentic_fabric.mocking.mock_crewai(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]¶
Mock CrewAI modules only.
- pytest_agentic_fabric.mocking.mock_langgraph(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]¶
Mock LangGraph modules only.
- pytest_agentic_fabric.mocking.mock_strands(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]¶
Mock Strands modules only.