AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fixing tests to fit latest merges into master
Itamar Friedman5a8700060e55
diff --git a/requirements.txt b/requirements.txtindex dbfa774183..210f06d067 100644--- a/requirements.txt+++ b/requirements.txt@@ -25,3 +25,5 @@ blacksourceryisortgitpython==3.1.31+pytest+pytest-mock\ No newline at end of filediff --git a/tests/local_cache_test.py b/tests/local_cache_test.pyindex 9ac6aa54d9..91c922b062 100644--- a/tests/local_cache_test.py+++ b/tests/local_cache_test.py@@ -1,5 +1,6 @@import osimport sys+import unittestfrom autogpt.memory.local import LocalCachediff --git a/tests/smoke_test.py b/tests/smoke_test.pyindex 8d33cf8987..50e97b7b41 100644--- a/tests/smoke_test.py+++ b/tests/smoke_test.py@@ -3,7 +3,7 @@ import subprocessimport sysimport unittest-from autogpt.file_operations import delete_file, read_file+from autogpt.commands.file_operations import delete_file, read_fileenv_vars = {"MEMORY_BACKEND": "no_memory", "TEMPERATURE": "0"}diff --git a/tests/unit/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.pyindex 0f051c1439..0a3340e739 100644--- a/tests/unit/test_browse_scrape_links.py+++ b/tests/unit/test_browse_scrape_links.py@@ -4,7 +4,7 @@# pip install pytest-mockimport pytest-from scripts.browse import scrape_links+from autogpt.commands.web_requests import scrape_links"""Code Analysis@@ -55,7 +55,7 @@ class TestScrapeLinks:mock_response.text = ("<html><body><a href='https://www.google.com'>Google</a></body></html>")- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function with a valid URLresult = scrape_links("https://www.example.com")@@ -68,7 +68,7 @@ class TestScrapeLinks:# Mock the requests.get() function to return an HTTP error responsemock_response = mocker.Mock()mock_response.status_code = 404- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function with an invalid URLresult = scrape_links("https://www.invalidurl.com")@@ -82,7 +82,7 @@ class TestScrapeLinks:mock_response = mocker.Mock()mock_response.status_code = 200mock_response.text = "<html><body><p>No hyperlinks here</p></body></html>"- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function with a URL containing no hyperlinksresult = scrape_links("https://www.example.com")@@ -105,7 +105,7 @@ class TestScrapeLinks:</body></html>"""- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function being testedresult = scrape_links("https://www.example.com")diff --git a/tests/unit/test_browse_scrape_text.py b/tests/unit/test_browse_scrape_text.pyindex 98f5f558ab..61c19b058d 100644--- a/tests/unit/test_browse_scrape_text.py+++ b/tests/unit/test_browse_scrape_text.py@@ -41,7 +41,7 @@ class TestScrapeText:mock_response = mocker.Mock()mock_response.status_code = 200mock_response.text = f"<html><body><div><p style='color: blue;'>{expected_text}</p></div></body></html>"- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function with a valid URL and assert that it returns the expected texturl = "http://www.example.com"@@ -50,7 +50,7 @@ class TestScrapeText:# Tests that the function returns an error message when an invalid or unreachable url is provided.def test_invalid_url(self, mocker):# Mock the requests.get() method to raise an exception- mocker.patch("requests.get", side_effect=requests.exceptions.RequestException)+ mocker.patch("requests.Session.get", side_effect=requests.exceptions.RequestException)# Call the function with an invalid URL and assert that it returns an error messageurl = "http://www.invalidurl.com"@@ -63,7 +63,7 @@ class TestScrapeText:mock_response = mocker.Mock()mock_response.status_code = 200mock_response.text = "<html><body></body></html>"- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function with a valid URL and assert that it returns an empty stringurl = "http://www.example.com"@@ -72,7 +72,7 @@ class TestScrapeText:# Tests that the function returns an error message when the response status code is an http error (>=400).def test_http_error(self, mocker):# Mock the requests.get() method to return a response with a 404 status code- mocker.patch("requests.get", return_value=mocker.Mock(status_code=404))+ mocker.patch("requests.Session.get", return_value=mocker.Mock(status_code=404))# Call the function with a URLresult = scrape_text("https://www.example.com")@@ -87,7 +87,7 @@ class TestScrapeText:mock_response = mocker.Mock()mock_response.status_code = 200mock_response.text = html- mocker.patch("requests.get", return_value=mock_response)+ mocker.patch("requests.Session.get", return_value=mock_response)# Call the function with a URLresult = scrape_text("https://www.example.com")diff --git a/tests/unit/test_commands.py b/tests/unit/test_commands.pyindex 21982f7e63..e15709aa37 100644--- a/tests/unit/test_commands.py+++ b/tests/unit/test_commands.py@@ -1,5 +1,5 @@import autogpt.agent.agent_manager as agent_manager-from autogpt.app import start_agent, list_agents+from autogpt.app import start_agent, list_agents, execute_commandimport unittestfrom unittest.mock import patch, MagicMock