fix(lint): resolve all ruff lint errors
Add ruff config to exclude alembic E402, SQLAlchemy F821, and pre-existing E501 line-length issues. Auto-fix 69 unused imports and 2 f-strings without placeholders. Manually fix 8 unused variables. Apply ruff format to 127 files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,53 +3,65 @@
|
||||
Verifies STOR-01 (table/column structure) and STOR-05 (config_text stores ciphertext).
|
||||
"""
|
||||
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import String, Text
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
||||
|
||||
def test_router_config_snapshot_importable():
|
||||
"""RouterConfigSnapshot can be imported from app.models."""
|
||||
from app.models import RouterConfigSnapshot
|
||||
|
||||
assert RouterConfigSnapshot is not None
|
||||
|
||||
|
||||
def test_router_config_diff_importable():
|
||||
"""RouterConfigDiff can be imported from app.models."""
|
||||
from app.models import RouterConfigDiff
|
||||
|
||||
assert RouterConfigDiff is not None
|
||||
|
||||
|
||||
def test_router_config_change_importable():
|
||||
"""RouterConfigChange can be imported from app.models."""
|
||||
from app.models import RouterConfigChange
|
||||
|
||||
assert RouterConfigChange is not None
|
||||
|
||||
|
||||
def test_snapshot_tablename():
|
||||
"""RouterConfigSnapshot.__tablename__ is correct."""
|
||||
from app.models import RouterConfigSnapshot
|
||||
|
||||
assert RouterConfigSnapshot.__tablename__ == "router_config_snapshots"
|
||||
|
||||
|
||||
def test_diff_tablename():
|
||||
"""RouterConfigDiff.__tablename__ is correct."""
|
||||
from app.models import RouterConfigDiff
|
||||
|
||||
assert RouterConfigDiff.__tablename__ == "router_config_diffs"
|
||||
|
||||
|
||||
def test_change_tablename():
|
||||
"""RouterConfigChange.__tablename__ is correct."""
|
||||
from app.models import RouterConfigChange
|
||||
|
||||
assert RouterConfigChange.__tablename__ == "router_config_changes"
|
||||
|
||||
|
||||
def test_snapshot_columns():
|
||||
"""RouterConfigSnapshot has all required columns."""
|
||||
from app.models import RouterConfigSnapshot
|
||||
|
||||
table = RouterConfigSnapshot.__table__
|
||||
expected = {"id", "device_id", "tenant_id", "config_text", "sha256_hash", "collected_at", "created_at"}
|
||||
expected = {
|
||||
"id",
|
||||
"device_id",
|
||||
"tenant_id",
|
||||
"config_text",
|
||||
"sha256_hash",
|
||||
"collected_at",
|
||||
"created_at",
|
||||
}
|
||||
actual = {c.name for c in table.columns}
|
||||
assert expected.issubset(actual), f"Missing columns: {expected - actual}"
|
||||
|
||||
@@ -57,10 +69,18 @@ def test_snapshot_columns():
|
||||
def test_diff_columns():
|
||||
"""RouterConfigDiff has all required columns."""
|
||||
from app.models import RouterConfigDiff
|
||||
|
||||
table = RouterConfigDiff.__table__
|
||||
expected = {
|
||||
"id", "device_id", "tenant_id", "old_snapshot_id", "new_snapshot_id",
|
||||
"diff_text", "lines_added", "lines_removed", "created_at",
|
||||
"id",
|
||||
"device_id",
|
||||
"tenant_id",
|
||||
"old_snapshot_id",
|
||||
"new_snapshot_id",
|
||||
"diff_text",
|
||||
"lines_added",
|
||||
"lines_removed",
|
||||
"created_at",
|
||||
}
|
||||
actual = {c.name for c in table.columns}
|
||||
assert expected.issubset(actual), f"Missing columns: {expected - actual}"
|
||||
@@ -69,10 +89,17 @@ def test_diff_columns():
|
||||
def test_change_columns():
|
||||
"""RouterConfigChange has all required columns."""
|
||||
from app.models import RouterConfigChange
|
||||
|
||||
table = RouterConfigChange.__table__
|
||||
expected = {
|
||||
"id", "diff_id", "device_id", "tenant_id",
|
||||
"component", "summary", "raw_line", "created_at",
|
||||
"id",
|
||||
"diff_id",
|
||||
"device_id",
|
||||
"tenant_id",
|
||||
"component",
|
||||
"summary",
|
||||
"raw_line",
|
||||
"created_at",
|
||||
}
|
||||
actual = {c.name for c in table.columns}
|
||||
assert expected.issubset(actual), f"Missing columns: {expected - actual}"
|
||||
@@ -81,6 +108,7 @@ def test_change_columns():
|
||||
def test_snapshot_config_text_is_text_type():
|
||||
"""config_text column type is Text (documents Transit ciphertext contract)."""
|
||||
from app.models import RouterConfigSnapshot
|
||||
|
||||
col = RouterConfigSnapshot.__table__.c.config_text
|
||||
assert isinstance(col.type, Text), f"Expected Text, got {type(col.type)}"
|
||||
|
||||
@@ -88,6 +116,7 @@ def test_snapshot_config_text_is_text_type():
|
||||
def test_snapshot_sha256_hash_is_string_64():
|
||||
"""sha256_hash column type is String(64) for plaintext hash deduplication."""
|
||||
from app.models import RouterConfigSnapshot
|
||||
|
||||
col = RouterConfigSnapshot.__table__.c.sha256_hash
|
||||
assert isinstance(col.type, String), f"Expected String, got {type(col.type)}"
|
||||
assert col.type.length == 64, f"Expected length 64, got {col.type.length}"
|
||||
|
||||
Reference in New Issue
Block a user