Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions backend/tests/test_orfs_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def set_platform():

mock_orfs_server._get_platforms_impl = Mock(side_effect=set_platform)

result = ORFSBase.get_platforms.fn()
result = ORFSBase.get_platforms()

assert result == "sky130hd"
assert mock_orfs_server.platform == "sky130hd"
Expand All @@ -205,7 +205,7 @@ def set_design():

mock_orfs_server._get_designs_impl = Mock(side_effect=set_design)

result = ORFSBase.get_designs.fn()
result = ORFSBase.get_designs()

assert result == "riscv32i"
assert mock_orfs_server.design == "riscv32i"
Expand All @@ -216,7 +216,7 @@ def test_make_tool(self, mock_orfs_server):
mock_orfs_server._check_configuration = Mock()
mock_orfs_server._command = Mock()

result = ORFSBase.make.fn("clean")
result = ORFSBase.make("clean")

mock_orfs_server._check_configuration.assert_called_once()
mock_orfs_server._command.assert_called_once_with("clean")
Expand All @@ -226,7 +226,7 @@ def test_get_stage_names(self, mock_orfs_server):
"""Test get_stage_names MCP tool."""
ORFS.server = mock_orfs_server

result = ORFSBase.get_stage_names.fn()
result = ORFSBase.get_stage_names()

assert "synth" in result
assert "floorplan" in result
Expand All @@ -242,7 +242,7 @@ def test_jump_valid_stage(self, mock_orfs_server):
mock_orfs_server._command = Mock()

with patch.dict(os.environ, {"DISABLE_GUI": "true"}):
result = ORFSBase.jump.fn("floorplan")
result = ORFSBase.jump("floorplan")

assert result == "finished floorplan"
assert mock_orfs_server.cur_stage == 1
Expand All @@ -254,7 +254,7 @@ def test_jump_invalid_stage(self, mock_orfs_server):
mock_orfs_server._check_configuration = Mock()
mock_orfs_server._command = Mock()

result = ORFSBase.jump.fn("invalid_stage")
result = ORFSBase.jump("invalid_stage")

assert result == "aborted invalid_stage"
mock_orfs_server._command.assert_not_called()
Expand All @@ -266,7 +266,7 @@ def test_jump_with_gui_enabled(self, mock_orfs_server):
mock_orfs_server._command = Mock()

with patch.dict(os.environ, {"DISABLE_GUI": "false"}):
_result = ORFSBase.jump.fn("synth")
_result = ORFSBase.jump("synth")

# Should call both synth and gui_synth
assert mock_orfs_server._command.call_count == 2
Expand All @@ -286,7 +286,7 @@ def command_side_effect(cmd):
mock_orfs_server._command = Mock(side_effect=command_side_effect)

with patch.dict(os.environ, {"DISABLE_GUI": "false"}):
result = ORFSBase.jump.fn("synth")
result = ORFSBase.jump("synth")

# Should still return success even though GUI failed
assert result == "finished synth"
Expand All @@ -299,7 +299,7 @@ def test_step_advances_stage(self, mock_orfs_server):
mock_orfs_server._command = Mock()

with patch.dict(os.environ, {"DISABLE_GUI": "true"}):
result = ORFSBase.step.fn()
result = ORFSBase.step()

assert mock_orfs_server.cur_stage == 1
assert result == "finished floorplan"
Expand All @@ -313,7 +313,7 @@ def test_step_at_end_of_pipeline(self, mock_orfs_server):
mock_orfs_server._command = Mock()

with patch.dict(os.environ, {"DISABLE_GUI": "true"}):
result = ORFSBase.step.fn()
result = ORFSBase.step()

# Should stay at stage 5
assert mock_orfs_server.cur_stage == 5
Expand All @@ -327,7 +327,7 @@ def test_step_with_gui_enabled(self, mock_orfs_server):
mock_orfs_server._command = Mock()

with patch.dict(os.environ, {"DISABLE_GUI": "false"}):
_result = ORFSBase.step.fn()
_result = ORFSBase.step()

# Should call both floorplan and gui_floorplan
assert mock_orfs_server._command.call_count == 2
Expand All @@ -339,11 +339,11 @@ def test_get_platforms_requires_server(self):
ORFS.server = None

with pytest.raises(AssertionError):
ORFSBase.get_platforms.fn()
ORFSBase.get_platforms()

def test_make_requires_server(self):
"""Test make fails without server initialization."""
ORFS.server = None

with pytest.raises(AssertionError):
ORFSBase.make.fn("synth")
ORFSBase.make("synth")
14 changes: 7 additions & 7 deletions backend/tests/test_orfs_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_create_dynamic_makefile_no_env_vars(self, mock_orfs_server):
mock_orfs_server.orfs_env = {}

# Access the underlying function from the FunctionTool
result = ORFSMake.create_dynamic_makefile.fn("test")
result = ORFSMake.create_dynamic_makefile("test")

assert result == "no env vars"

Expand All @@ -85,7 +85,7 @@ def test_create_dynamic_makefile_with_env_vars(self, mock_orfs_server, tmp_path)
"CORE_UTILIZATION": "50",
}

result = ORFSMake.create_dynamic_makefile.fn("test")
result = ORFSMake.create_dynamic_makefile("test")

# Check dynamic_makefile flag is set
assert mock_orfs_server.dynamic_makefile is True
Expand Down Expand Up @@ -133,7 +133,7 @@ def set_design():
mock_orfs_server._get_platforms_impl.side_effect = set_platform
mock_orfs_server._get_designs_impl.side_effect = set_design

_result = ORFSMake.create_dynamic_makefile.fn("test")
_result = ORFSMake.create_dynamic_makefile("test")

# Verify initialization was called
mock_orfs_server._get_designs_impl.assert_called_once()
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_get_env_vars_success(
return_value=Mock(__or__=Mock(return_value=mock_chain))
)

result = ORFSMake.get_env_vars.fn("get clock and utilization variables")
result = ORFSMake.get_env_vars("get clock and utilization variables")

# Check return value
assert result == "done env"
Expand All @@ -185,15 +185,15 @@ def test_get_env_vars_requires_server(self):
ORFS.server = None

with pytest.raises(AssertionError):
ORFSMake.get_env_vars.fn("test")
ORFSMake.get_env_vars("test")

def test_get_env_vars_requires_llm(self, mock_orfs_server):
"""Test get_env_vars fails without LLM initialization."""
ORFS.server = mock_orfs_server
ORFS.llm = None

with pytest.raises(AssertionError):
ORFSMake.get_env_vars.fn("test")
ORFSMake.get_env_vars("test")

def test_create_dynamic_makefile_with_makefile_syntax(
self, mock_orfs_server, tmp_path
Expand All @@ -206,7 +206,7 @@ def test_create_dynamic_makefile_with_makefile_syntax(
"DIE_AREA": "$(PLATFORM_DIR)/$(DESIGN_NAME)", # Variable reference
}

_result = ORFSMake.create_dynamic_makefile.fn("test")
_result = ORFSMake.create_dynamic_makefile("test")

# Check file was created
expected_path = f"{mock_orfs_server.flow_dir}/designs/{mock_orfs_server.platform}/{mock_orfs_server.design}/dynamic_config.mk"
Expand Down
24 changes: 12 additions & 12 deletions backend/tests/test_orfs_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_retrieve_general_success(self, mock_format_docs):
["link1"],
)

result = ORFSRag.retrieve_general.fn("test query")
result = ORFSRag.retrieve_general("test query")

# Verify retriever was called
mock_retriever.invoke.assert_called_once_with(input="test query")
Expand All @@ -77,7 +77,7 @@ def test_retrieve_general_not_initialized(self):
ORFS.general_retriever = None

with pytest.raises(ValueError, match="General Retriever not initialized"):
ORFSRag.retrieve_general.fn("test query")
ORFSRag.retrieve_general("test query")

@patch("src.openroad_mcp.server.orfs.orfs_rag.format_docs")
def test_retrieve_cmds_success(self, mock_format_docs):
Expand All @@ -96,7 +96,7 @@ def test_retrieve_cmds_success(self, mock_format_docs):
["link1"],
)

result = ORFSRag.retrieve_cmds.fn("make command")
result = ORFSRag.retrieve_cmds("make command")

# Verify retriever was called
mock_retriever.invoke.assert_called_once_with(input="make command")
Expand All @@ -109,7 +109,7 @@ def test_retrieve_cmds_not_initialized(self):
ORFS.commands_retriever = None

with pytest.raises(ValueError, match="Commands Retriever not initialized"):
ORFSRag.retrieve_cmds.fn("test query")
ORFSRag.retrieve_cmds("test query")

@patch("src.openroad_mcp.server.orfs.orfs_rag.format_docs")
def test_retrieve_install_success(self, mock_format_docs):
Expand All @@ -128,7 +128,7 @@ def test_retrieve_install_success(self, mock_format_docs):
["link1"],
)

result = ORFSRag.retrieve_install.fn("installation steps")
result = ORFSRag.retrieve_install("installation steps")

# Verify retriever was called
mock_retriever.invoke.assert_called_once_with(input="installation steps")
Expand All @@ -141,7 +141,7 @@ def test_retrieve_install_not_initialized(self):
ORFS.install_retriever = None

with pytest.raises(ValueError, match="Install Retriever not initialized"):
ORFSRag.retrieve_install.fn("test query")
ORFSRag.retrieve_install("test query")

@patch("src.openroad_mcp.server.orfs.orfs_rag.format_docs")
def test_retrieve_errinfo_success(self, mock_format_docs):
Expand All @@ -160,7 +160,7 @@ def test_retrieve_errinfo_success(self, mock_format_docs):
["link1"],
)

result = ORFSRag.retrieve_errinfo.fn("ANT-0001")
result = ORFSRag.retrieve_errinfo("ANT-0001")

# Verify retriever was called
mock_retriever.invoke.assert_called_once_with(input="ANT-0001")
Expand All @@ -173,7 +173,7 @@ def test_retrieve_errinfo_not_initialized(self):
ORFS.errinfo_retriever = None

with pytest.raises(ValueError, match="Error Info Retriever not initialized"):
ORFSRag.retrieve_errinfo.fn("test query")
ORFSRag.retrieve_errinfo("test query")

@patch("src.openroad_mcp.server.orfs.orfs_rag.format_docs")
def test_retrieve_yosys_rtdocs_success(self, mock_format_docs):
Expand All @@ -192,7 +192,7 @@ def test_retrieve_yosys_rtdocs_success(self, mock_format_docs):
["link1"],
)

result = ORFSRag.retrieve_yosys_rtdocs.fn("yosys synthesis")
result = ORFSRag.retrieve_yosys_rtdocs("yosys synthesis")

# Verify retriever was called
mock_retriever.invoke.assert_called_once_with(input="yosys synthesis")
Expand All @@ -205,7 +205,7 @@ def test_retrieve_yosys_rtdocs_not_initialized(self):
ORFS.yosys_rtdocs_retriever = None

with pytest.raises(ValueError, match="Yosys RTDocs Retriever not initialized"):
ORFSRag.retrieve_yosys_rtdocs.fn("test query")
ORFSRag.retrieve_yosys_rtdocs("test query")

@patch("src.openroad_mcp.server.orfs.orfs_rag.format_docs")
def test_retrieve_klayout_docs_success(self, mock_format_docs):
Expand All @@ -224,7 +224,7 @@ def test_retrieve_klayout_docs_success(self, mock_format_docs):
["link1"],
)

result = ORFSRag.retrieve_klayout_docs.fn("klayout usage")
result = ORFSRag.retrieve_klayout_docs("klayout usage")

# Verify retriever was called
mock_retriever.invoke.assert_called_once_with(input="klayout usage")
Expand All @@ -237,4 +237,4 @@ def test_retrieve_klayout_docs_not_initialized(self):
ORFS.klayout_retriever = None

with pytest.raises(ValueError, match="KLayout Retriever not initialized"):
ORFSRag.retrieve_klayout_docs.fn("test query")
ORFSRag.retrieve_klayout_docs("test query")
Loading
Loading