From caf306d07dc77586b36461257af0debaf7541b20 Mon Sep 17 00:00:00 2001 From: Andres Caicedo Date: Thu, 20 Apr 2023 21:31:37 +0200 Subject: [PATCH] Black formatted tests files --- tests/browse_tests.py | 1 + tests/integration/memory_tests.py | 1 + tests/integration/weaviate_memory_tests.py | 1 + tests/test_commands.py | 3 ++- tests/test_image_gen.py | 1 + tests/test_json_parser.py | 1 + tests/test_token_counter.py | 1 + tests/unit/json_tests.py | 1 + tests/unit/models/test_base_open_api_plugin.py | 1 + tests/unit/test_browse_scrape_links.py | 1 + tests/unit/test_browse_scrape_text.py | 3 ++- tests/unit/test_chat.py | 1 + tests/unit/test_plugins.py | 5 +++++ 13 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/browse_tests.py b/tests/browse_tests.py index 297b6390cc46..70c465c85e6b 100644 --- a/tests/browse_tests.py +++ b/tests/browse_tests.py @@ -11,6 +11,7 @@ class TestBrowseLinks(unittest.TestCase): """Class for testing the extract_hyperlinks function""" + def test_extract_hyperlinks(self): """Test the extract_hyperlinks function""" body = """ diff --git a/tests/integration/memory_tests.py b/tests/integration/memory_tests.py index 09165eaf3c4d..35c7fb360715 100644 --- a/tests/integration/memory_tests.py +++ b/tests/integration/memory_tests.py @@ -10,6 +10,7 @@ class TestLocalCache(unittest.TestCase): """Tests for LocalCache class""" + def random_string(self, length): """Generate a random string of fixed length""" return "".join(random.choice(string.ascii_letters) for _ in range(length)) diff --git a/tests/integration/weaviate_memory_tests.py b/tests/integration/weaviate_memory_tests.py index dbac42917353..7783bf684aea 100644 --- a/tests/integration/weaviate_memory_tests.py +++ b/tests/integration/weaviate_memory_tests.py @@ -14,6 +14,7 @@ class TestWeaviateMemory(unittest.TestCase): """Tests for the WeaviateMemory class.""" + cfg = None client = None index = None diff --git a/tests/test_commands.py b/tests/test_commands.py index 0fd7f735818a..453c6335be07 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -9,7 +9,8 @@ class TestCommand: - """ Test cases for the Command class.""" + """Test cases for the Command class.""" + @staticmethod def example_function(arg1: int, arg2: str) -> str: """Example function for testing the Command class.""" diff --git a/tests/test_image_gen.py b/tests/test_image_gen.py index dd261739234b..f4f33ac3cd2c 100644 --- a/tests/test_image_gen.py +++ b/tests/test_image_gen.py @@ -17,6 +17,7 @@ def lst(txt): @unittest.skipIf(os.getenv("CI"), "Skipping image generation tests") class TestImageGen(unittest.TestCase): """Test image generation.""" + def setUp(self): """Set up the test class.""" self.config = Config() diff --git a/tests/test_json_parser.py b/tests/test_json_parser.py index 1e740843da92..ffa45aff50d7 100644 --- a/tests/test_json_parser.py +++ b/tests/test_json_parser.py @@ -6,6 +6,7 @@ class TestParseJson(unittest.TestCase): """Test the JSON parser.""" + def test_valid_json(self): """Test that a valid JSON string can be parsed.""" json_str = '{"name": "John", "age": 30, "city": "New York"}' diff --git a/tests/test_token_counter.py b/tests/test_token_counter.py index 52b9b1110bde..bba9107d4722 100644 --- a/tests/test_token_counter.py +++ b/tests/test_token_counter.py @@ -6,6 +6,7 @@ class TestTokenCounter(unittest.TestCase): """Test the token counter.""" + def test_count_message_tokens(self): """Test that the message tokens are counted correctly.""" messages = [ diff --git a/tests/unit/json_tests.py b/tests/unit/json_tests.py index 17d9236c5a96..0fe30619ea4d 100644 --- a/tests/unit/json_tests.py +++ b/tests/unit/json_tests.py @@ -5,6 +5,7 @@ class TestParseJson(unittest.TestCase): """Test the JSON parser.""" + def test_valid_json(self): # Test that a valid JSON string is parsed correctly json_str = '{"name": "John", "age": 30, "city": "New York"}' diff --git a/tests/unit/models/test_base_open_api_plugin.py b/tests/unit/models/test_base_open_api_plugin.py index 26f97b5ad261..456c74c762af 100644 --- a/tests/unit/models/test_base_open_api_plugin.py +++ b/tests/unit/models/test_base_open_api_plugin.py @@ -11,6 +11,7 @@ class DummyPlugin(BaseOpenAIPlugin): """A dummy plugin for testing purposes.""" + pass diff --git a/tests/unit/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.py index 031143353ee7..43b3e93196ab 100644 --- a/tests/unit/test_browse_scrape_links.py +++ b/tests/unit/test_browse_scrape_links.py @@ -39,6 +39,7 @@ class TestScrapeLinks: """Tests for the scrape_links function.""" + # Tests that the function returns a list of formatted hyperlinks when # provided with a valid url that returns a webpage with hyperlinks. def test_valid_url_with_hyperlinks(self): diff --git a/tests/unit/test_browse_scrape_text.py b/tests/unit/test_browse_scrape_text.py index 69e0c0d43203..39f69c8ee723 100644 --- a/tests/unit/test_browse_scrape_text.py +++ b/tests/unit/test_browse_scrape_text.py @@ -42,6 +42,7 @@ class TestScrapeText: """Tests for the scrape_text function.""" + # Tests that scrape_text() returns the expected text when given a valid URL. def test_scrape_text_with_valid_url(self, mocker): # Mock the requests.get() method to return a response with expected text @@ -77,7 +78,7 @@ def test_invalid_url(self, mocker): # Tests that the function returns an empty string when the html page contains no # text to be scraped. def test_no_text(self, mocker): - """"Test that the function returns an empty string when the html page contains no text to be scraped.""" + """ "Test that the function returns an empty string when the html page contains no text to be scraped.""" # Mock the requests.get() method to return a response with no text mock_response = mocker.Mock() mock_response.status_code = 200 diff --git a/tests/unit/test_chat.py b/tests/unit/test_chat.py index a3851c6e80f2..e1cb3554ce28 100644 --- a/tests/unit/test_chat.py +++ b/tests/unit/test_chat.py @@ -8,6 +8,7 @@ class TestChat(unittest.TestCase): """Test the chat functions.""" + # Tests that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content. def test_happy_path_role_content(self): """Test that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content.""" diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py index 6ff0bcf6cfcc..7c5ee53e91ad 100644 --- a/tests/unit/test_plugins.py +++ b/tests/unit/test_plugins.py @@ -23,8 +23,10 @@ def test_inspect_zip_for_module(): @pytest.fixture def mock_config_denylist_allowlist_check(): """Mock config object for testing the denylist_allowlist_check function""" + class MockConfig: """Mock config object for testing the denylist_allowlist_check function""" + plugins_denylist = ["BadPlugin"] plugins_allowlist = ["GoodPlugin"] @@ -97,8 +99,10 @@ def config_with_plugins(): @pytest.fixture def mock_config_openai_plugin(): """Mock config object for testing the scan_plugins function""" + class MockConfig: """Mock config object for testing the scan_plugins function""" + plugins_dir = PLUGINS_TEST_DIR plugins_openai = [PLUGIN_TEST_OPENAI] plugins_denylist = ["AutoGPTPVicuna"] @@ -117,6 +121,7 @@ def test_scan_plugins_openai(mock_config_openai_plugin): @pytest.fixture def mock_config_generic_plugin(): """Mock config object for testing the scan_plugins function""" + # Test that the function returns the correct number of plugins class MockConfig: plugins_dir = PLUGINS_TEST_DIR