"""Tests for constants module."""
from cisco_catalog_mcp.constants import (
AVAILABILITY_ATTRIBUTES,
BASIC_ATTRIBUTES,
EOL_ATTRIBUTES,
ERROR_CODES,
ITEM_ATTRIBUTES,
PHYSICAL_ATTRIBUTES,
PRICE_LISTS,
PRICING_ATTRIBUTES,
SERVICE_ATTRIBUTES,
)
class TestItemAttributes:
"""Tests for item attributes."""
def test_item_attributes_not_empty(self) -> None:
"""Test that item attributes list is populated."""
assert len(ITEM_ATTRIBUTES) > 0
def test_core_attributes_present(self) -> None:
"""Test that core attributes are in the list."""
core_attrs = [
"ListPrice",
"ProductType",
"ERPFamily",
"EoX",
"LeadTime",
"WebOrderable",
"SmartLicensingEnabled",
]
for attr in core_attrs:
assert attr in ITEM_ATTRIBUTES, f"{attr} should be in ITEM_ATTRIBUTES"
def test_no_duplicate_attributes(self) -> None:
"""Test that there are no duplicate attributes."""
assert len(ITEM_ATTRIBUTES) == len(set(ITEM_ATTRIBUTES))
class TestAttributeGroups:
"""Tests for attribute group constants."""
def test_basic_attributes(self) -> None:
"""Test basic attributes group."""
assert "ListPrice" in BASIC_ATTRIBUTES
assert "ProductType" in BASIC_ATTRIBUTES
assert len(BASIC_ATTRIBUTES) > 0
def test_pricing_attributes(self) -> None:
"""Test pricing attributes group."""
assert "ListPrice" in PRICING_ATTRIBUTES
assert "PriceListShortName" in PRICING_ATTRIBUTES
assert len(PRICING_ATTRIBUTES) > 0
def test_availability_attributes(self) -> None:
"""Test availability attributes group."""
assert "WebOrderable" in AVAILABILITY_ATTRIBUTES
assert "LeadTime" in AVAILABILITY_ATTRIBUTES
assert len(AVAILABILITY_ATTRIBUTES) > 0
def test_eol_attributes(self) -> None:
"""Test EOL attributes group."""
assert "EoX" in EOL_ATTRIBUTES
assert len(EOL_ATTRIBUTES) > 0
def test_service_attributes(self) -> None:
"""Test service attributes group."""
assert "ServiceIndicator" in SERVICE_ATTRIBUTES
assert "ServiceProgram" in SERVICE_ATTRIBUTES
assert len(SERVICE_ATTRIBUTES) > 0
def test_physical_attributes(self) -> None:
"""Test physical attributes group."""
assert "ProductDimension" in PHYSICAL_ATTRIBUTES
assert "Weight" in PHYSICAL_ATTRIBUTES
assert len(PHYSICAL_ATTRIBUTES) > 0
def test_groups_are_subsets_of_all_attributes(self) -> None:
"""Test that all group attributes are in the main list."""
all_group_attrs = (
BASIC_ATTRIBUTES
+ PRICING_ATTRIBUTES
+ AVAILABILITY_ATTRIBUTES
+ EOL_ATTRIBUTES
+ SERVICE_ATTRIBUTES
+ PHYSICAL_ATTRIBUTES
)
for attr in all_group_attrs:
assert attr in ITEM_ATTRIBUTES, f"{attr} from groups not in ITEM_ATTRIBUTES"
class TestPriceLists:
"""Tests for price list constants."""
def test_price_lists_not_empty(self) -> None:
"""Test that price lists are populated."""
assert len(PRICE_LISTS) > 0
def test_glus_present(self) -> None:
"""Test that GLUS (US) price list is present."""
assert "GLUS" in PRICE_LISTS
assert PRICE_LISTS["GLUS"]["id"] == "1109"
assert PRICE_LISTS["GLUS"]["currency"] == "USD"
def test_price_list_structure(self) -> None:
"""Test that all price lists have required fields."""
for code, data in PRICE_LISTS.items():
assert "id" in data, f"{code} missing 'id'"
assert "description" in data, f"{code} missing 'description'"
assert "currency" in data, f"{code} missing 'currency'"
def test_common_price_lists(self) -> None:
"""Test that common price lists are present."""
common = ["GLUS", "GLEMEA", "GLEURO", "GLGB", "GLCA"]
for code in common:
assert code in PRICE_LISTS, f"{code} should be in PRICE_LISTS"
class TestErrorCodes:
"""Tests for error code constants."""
def test_error_codes_not_empty(self) -> None:
"""Test that error codes are populated."""
assert len(ERROR_CODES) > 0
def test_success_code_present(self) -> None:
"""Test that success code is present."""
assert "CC001H" in ERROR_CODES
assert ERROR_CODES["CC001H"] == "Success"
def test_common_error_codes_present(self) -> None:
"""Test that common error codes are present."""
common = ["CC001H", "CC002H", "CC003H", "CC007H", "CC009H"]
for code in common:
assert code in ERROR_CODES, f"{code} should be in ERROR_CODES"