Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

bugfix: mermaid unittest

voidkingeae92fac267c
diff --git a/tests/metagpt/utils/test_mermaid.py b/tests/metagpt/utils/test_mermaid.py
index 912453aaf..b7b97a3f1 100644
--- a/tests/metagpt/utils/test_mermaid.py
+++ b/tests/metagpt/utils/test_mermaid.py
@@ -10,29 +10,31 @@ import pytest
from metagpt.config import CONFIG
from metagpt.utils.common import check_cmd_exists
-from metagpt.utils.mermaid import MMC1, MMC2, mermaid_to_file
+from metagpt.utils.mermaid import MMC1, mermaid_to_file
@pytest.mark.asyncio
[email protected]("engine", ["nodejs", "playwright", "pyppeteer", "ink"])
[email protected]("engine", ["nodejs", "ink"]) # TODO: playwright and pyppeteer
async def test_mermaid(engine):
- # Prerequisites
- # npm install -g @mermaid-js/mermaid-cli
+ # nodejs prerequisites: npm install -g @mermaid-js/mermaid-cli
+ # ink prerequisites: connected to internet
+ # playwright prerequisites: playwright install --with-deps chromium
assert check_cmd_exists("npm") == 0
assert CONFIG.PYPPETEER_EXECUTABLE_PATH
CONFIG.mermaid_engine = engine
save_to = CONFIG.git_repo.workdir / f"{CONFIG.mermaid_engine}/1"
await mermaid_to_file(MMC1, save_to)
- for ext in [".pdf", ".svg", ".png"]:
- assert save_to.with_suffix(ext).exists()
- save_to.with_suffix(ext).unlink(missing_ok=True)
-
- save_to = CONFIG.git_repo.workdir / f"{CONFIG.mermaid_engine}/2"
- await mermaid_to_file(MMC2, save_to)
- for ext in [".pdf", ".svg", ".png"]:
- assert save_to.with_suffix(ext).exists()
- save_to.with_suffix(ext).unlink(missing_ok=True)
+
+ # ink does not support pdf
+ if engine == "ink":
+ for ext in [".svg", ".png"]:
+ assert save_to.with_suffix(ext).exists()
+ save_to.with_suffix(ext).unlink(missing_ok=True)
+ else:
+ for ext in [".pdf", ".svg", ".png"]:
+ assert save_to.with_suffix(ext).exists()
+ save_to.with_suffix(ext).unlink(missing_ok=True)
if __name__ == "__main__":