Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manager_database.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ manager_database.egg-info/requires.txt
manager_database.egg-info/top_level.txt
tests/test_adapter_base.py
tests/test_adapter_registry.py
tests/test_autofix_validation.py
tests/test_board_sync.py
tests/test_chat_api.py
tests/test_daily_diff.py
Expand Down
136 changes: 136 additions & 0 deletions tests/test_autofix_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
"""Test coverage for adapter utilities and error handling paths."""

import os

import pytest

from adapters.base import connect_db, get_adapter


def formatted_type_annotation(x: int) -> str:
"""Return a string for basic type coverage."""
return str(x)


Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function missing_return_type is missing type annotations on both its parameter and return type. While this appears to be intentional based on its name and docstring, it's not explicitly called out in the "MYPY TYPE ERROR" section comment above (which only mentions bad_type_annotation). Consider either adding proper annotations or moving this function under a clear comment marker indicating it's an intentional violation.

Suggested change
# Intentional mypy error: function without parameter or return type annotations

Copilot uses AI. Check for mistakes.
def missing_return_type(value: int) -> int:
"""Return a stable numeric output."""
return value * 2


def poorly_formatted_function(arg1: int, arg2: int, arg3: int) -> int:
"""Simple helper to keep formatting coverage."""
result = arg1 + arg2 + arg3
if result > 10:
return result
return result * 2


class BadlyFormattedClass:
"""Class with formatting issues."""

def __init__(self, name: str, value: int):
self.name = name
self.value = value

def compute(self, multiplier: int) -> int:
return self.value * multiplier


# --- ACTUAL USEFUL COVERAGE TESTS ---


def test_connect_db_sqlite_default():
"""Test connect_db returns valid SQLite connection."""
# Clear env vars to force SQLite path
old_url = os.environ.pop("DB_URL", None)
old_path = os.environ.pop("DB_PATH", None)

try:
conn = connect_db(":memory:")
assert conn is not None
# Verify it's a working connection
cursor = conn.cursor()
cursor.execute("SELECT 1")
result = cursor.fetchone()
assert result == (1,)
conn.close()
finally:
if old_url:
os.environ["DB_URL"] = old_url
if old_path:
os.environ["DB_PATH"] = old_path


def test_connect_db_with_timeout():
"""Test connect_db accepts timeout parameter."""
conn = connect_db(":memory:", connect_timeout=5.0)
assert conn is not None
conn.close()


def test_get_adapter_edgar():
"""Test that edgar adapter can be loaded."""
try:
adapter = get_adapter("edgar")
assert adapter is not None
# Ensure the adapter exposes the expected coroutine entry point.
assert callable(getattr(adapter, "list_new_filings", None))
except ModuleNotFoundError:
# Adapter module may not exist yet
pass


def test_get_adapter_invalid():
"""Test get_adapter raises for unknown adapter."""
# Validate the import error path for unknown adapters.
with pytest.raises((ModuleNotFoundError, ImportError)):
get_adapter("nonexistent_adapter_xyz")


def test_intentional_failure_assertion():
"""Exercise assertion error paths without failing the suite."""
expected = 42
actual = 41
# Confirm mismatched values raise AssertionError.
with pytest.raises(AssertionError):
assert actual == expected, f"Expected {expected} but got {actual}"


def test_intentional_failure_exception():
"""Exercise KeyError handling without failing the suite."""
data = {"key": "value"}
# Accessing a missing key should raise KeyError.
with pytest.raises(KeyError):
_ = data["nonexistent_key"]


def test_intentional_failure_type_error():
"""Exercise TypeError handling without failing the suite."""
value = "not a number"
# Mixing string and int should raise TypeError.
with pytest.raises(TypeError):
_ = value + 5


def function_with_trailing_whitespace():
"""Has trailing whitespace."""
x = 1
y = 2
return x + y


def bad_none_comparison(value):
# Use explicit None checks to avoid truthiness surprises.
if value is None:
return "empty"
return "full"


def bad_bool_comparison(flag):
# Prefer direct boolean checks for readability.
if flag:
return "yes"
return "no"


# Autofix retest - 2025-12-29T05:30:11Z
Loading