mcaxl/tests/test_normalize.py
Ryan Malloy ca6956e826 Rename to mcaxl + scrub for public PyPI release
Renames the package from `mcp-cucm-axl` to `mcaxl` to fit the
operator's mc<interface> naming convention (mcusb, mcaxl, …),
and scrubs Bingham-specific defaults so the package works for
anyone, anywhere.

Rename:
  - pyproject.toml: name, scripts entry point, description
  - src/mcp_cucm_axl/ → src/mcaxl/ (git mv preserves history)
  - All Python imports updated via sed
  - Cache directory: ~/.cache/mcp-cucm-axl/ → ~/.cache/mcaxl/
  - Log prefix [mcp-cucm-axl] → [mcaxl]
  - Package version lookup: importlib.metadata.version("mcaxl")
  - .mcp.json command updated to invoke `mcaxl` script
  - All 155 tests pass under the new name (verified)

Bingham-specific scrubs:
  - docs_loader._DEFAULT_INDEX_DIR: hardcoded /home/rpm/bingham/...
    path removed; defaults to None. Operators set CISCO_DOCS_INDEX_PATH
    env var; without it, prompts gracefully degrade with a fallback
    notice instructing the LLM to use the cisco-docs MCP search_docs
    tool instead.
  - prompts/_common.docs_or_empty_msg: removed the explicit
    /home/rpm/bingham/... path from the fallback message text.
  - server.py: removed dead-code copy of _docs_or_empty_msg() that
    was leftover from before the prompts package extraction.
  - README.md: completely rewritten as a public-facing readme. Lead
    paragraph names CUCM as the target platform, install instructions
    cover uvx / pip / Claude Code MCP add. Recommends cisco-cucm-mcp
    as the operations counterpart.

PyPI metadata:
  - Initial CalVer version: 2026.04.27
  - License: MIT (LICENSE file added)
  - Project URLs: Homepage / Source / Issues / Changelog all point
    at git.supported.systems/mcp/mcaxl (newly-created Gitea repo
    in the mcp/ org for PyPI releases)
  - Classifiers: Beta / Telecommunications Industry / Topic:Telephony
  - Keywords: mcp, cisco, cucm, axl, risport, voip, sip, audit
  - sdist excludes: CLAUDE.md, .env*, axlsqltoolkit.zip, audits/,
    tests/, pytest/ruff caches. Verified clean: wheel ships only the
    mcaxl/ source tree + LICENSE + METADATA + entry_points.

CHANGELOG.md added with a 2026.04.27 initial-release entry,
documenting tool/prompt counts, structural read-only guarantees,
Hamilton review closure, live-cluster verification, and known
limitations.

Build verification:
  - `uv build` produces clean wheel + sdist
  - Wheel: 22 source files, 195KB total, no Bingham-specific files
  - Sdist excludes verified: no CLAUDE.md, no axlsqltoolkit.zip
  - Entry point: `mcaxl = mcaxl.server:main`
  - Package installs as mcaxl==2026.4.27
2026-04-27 12:53:54 -06:00

71 lines
2.2 KiB
Python

"""Tests for value normalization (Informix t/f → bool, etc.)."""
import pytest
from mcaxl.normalize import (
BOOLEAN_COLUMNS,
normalize_bool,
normalize_row,
normalize_rows,
)
class TestNormalizeBool:
def test_t_becomes_true(self):
assert normalize_bool("t") is True
def test_f_becomes_false(self):
assert normalize_bool("f") is False
def test_passthrough_other_strings(self):
assert normalize_bool("True") == "True"
assert normalize_bool("yes") == "yes"
def test_passthrough_native_types(self):
assert normalize_bool(None) is None
assert normalize_bool(0) == 0
assert normalize_bool(True) is True
assert normalize_bool([]) == []
class TestNormalizeRow:
def test_normalizes_known_boolean_columns(self):
row = {"block_enabled": "t", "name": "RP-1", "ismessagewaitingon": "f"}
result = normalize_row(row)
assert result["block_enabled"] is True
assert result["ismessagewaitingon"] is False
assert result["name"] == "RP-1" # not a boolean column, untouched
def test_unknown_column_with_t_value_unchanged(self):
# Conservative: only normalize columns we know are boolean.
# Avoids false positives on columns where 't' is meaningful (e.g.
# a single-character device class code).
row = {"unknown_field": "t"}
result = normalize_row(row)
assert result["unknown_field"] == "t"
def test_empty_row(self):
assert normalize_row({}) == {}
class TestNormalizeRows:
def test_processes_each_row(self):
rows = [
{"block_enabled": "t", "name": "RP-1"},
{"block_enabled": "f", "name": "RP-2"},
]
result = normalize_rows(rows)
assert result[0]["block_enabled"] is True
assert result[1]["block_enabled"] is False
def test_empty_list(self):
assert normalize_rows([]) == []
class TestBooleanColumnsSet:
def test_known_columns_present(self):
# Smoke test that the canonical columns are in the set
assert "block_enabled" in BOOLEAN_COLUMNS
assert "blockenable" in BOOLEAN_COLUMNS
assert "isemergencyservicenumber" in BOOLEAN_COLUMNS