Skip to content

Commit

Permalink
replace *.deepwisdom.ai for scraping by local server
Browse files Browse the repository at this point in the history
  • Loading branch information
shenchucheng committed Feb 20, 2024
1 parent 8a9c7d9 commit 8d3c055
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ async def start():
await runner.setup()
site = aiohttp.web.TCPSite(runner, "localhost", 0)
await site.start()
host, port = site._server.sockets[0].getsockname()
return site, f"http://{host}:{port}"
port = site._server.sockets[0].getsockname()[1]
return site, f"http://127.0.0.1:{port}"

return start

Expand Down
6 changes: 3 additions & 3 deletions tests/metagpt/tools/test_web_browser_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

@pytest.mark.asyncio
@pytest.mark.parametrize(
"browser_type,",
"browser_type",
[
(WebBrowserEngineType.PLAYWRIGHT,),
(WebBrowserEngineType.SELENIUM,),
WebBrowserEngineType.PLAYWRIGHT,
WebBrowserEngineType.SELENIUM,
],
ids=["playwright", "selenium"],
)
Expand Down
3 changes: 2 additions & 1 deletion tests/metagpt/tools/test_web_browser_engine_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ async def test_scrape_web_page(browser_type, use_proxy, kwagrs, proxy, capfd, ht
assert len(results) == len(urls) + 1
assert all(("MetaGPT" in i.inner_text) for i in results)
if use_proxy:
await proxy_server.close()
proxy_server.close()
await proxy_server.wait_closed()
assert "Proxy:" in capfd.readouterr().out
await server.stop()

Expand Down
12 changes: 6 additions & 6 deletions tests/metagpt/tools/test_web_browser_engine_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ async def test_scrape_web_page(browser_type, use_proxy, proxy, capfd, http_serve
assert isinstance(result, WebPage)
assert "MetaGPT" in result.inner_text

if urls:
results = await browser.run(url, *urls)
assert isinstance(results, list)
assert len(results) == len(urls) + 1
assert all(("MetaGPT" in i.inner_text) for i in results)
results = await browser.run(url, *urls)
assert isinstance(results, list)
assert len(results) == len(urls) + 1
assert all(("MetaGPT" in i.inner_text) for i in results)
if use_proxy:
await proxy_server.close()
proxy_server.close()
await proxy_server.wait_closed()
assert "Proxy:" in capfd.readouterr().out
await server.stop()

Expand Down

0 comments on commit 8d3c055

Please sign in to comment.