Skip to content

Commit

Permalink
Black formatted tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresCdo committed Apr 20, 2023
1 parent 87f2ecd commit caf306d
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/browse_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
1 change: 1 addition & 0 deletions tests/integration/memory_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions tests/integration/weaviate_memory_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

class TestWeaviateMemory(unittest.TestCase):
"""Tests for the WeaviateMemory class."""

cfg = None
client = None
index = None
Expand Down
3 changes: 2 additions & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_image_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions tests/test_json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}'
Expand Down
1 change: 1 addition & 0 deletions tests/test_token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions tests/unit/json_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}'
Expand Down
1 change: 1 addition & 0 deletions tests/unit/models/test_base_open_api_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class DummyPlugin(BaseOpenAIPlugin):
"""A dummy plugin for testing purposes."""

pass


Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_browse_scrape_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_browse_scrape_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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"]
Expand All @@ -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
Expand Down

0 comments on commit caf306d

Please sign in to comment.