Home / Class/ TestCreditCardDetection Class — langchain Architecture

TestCreditCardDetection Class — langchain Architecture

Architecture documentation for the TestCreditCardDetection class in test_pii.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105["TestCreditCardDetection"]
  6dcffc03_fae9_01f8_ed9b_d30d8a73dd13["test_pii.py"]
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105 -->|defined in| 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13
  1862d357_0153_23f2_690d_46c8836db9a3["test_detect_valid_credit_card()"]
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105 -->|method| 1862d357_0153_23f2_690d_46c8836db9a3
  e115c24c_cf8b_bc65_3cfb_56d11237f7f1["test_detect_credit_card_with_spaces()"]
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105 -->|method| e115c24c_cf8b_bc65_3cfb_56d11237f7f1
  9e658dbb_3816_2e21_24b3_1ccc90b8f899["test_detect_credit_card_with_dashes()"]
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105 -->|method| 9e658dbb_3816_2e21_24b3_1ccc90b8f899
  81b824b0_0ca4_fdaa_4163_50864b06a5ca["test_invalid_luhn_not_detected()"]
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105 -->|method| 81b824b0_0ca4_fdaa_4163_50864b06a5ca
  25b4ae99_c796_4e01_5ee1_d196b025047c["test_no_credit_card()"]
  6c7a1b0c_679a_9f4c_e9a9_c33205da0105 -->|method| 25b4ae99_c796_4e01_5ee1_d196b025047c

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 61–97

class TestCreditCardDetection:
    """Test credit card detection with Luhn validation."""

    def test_detect_valid_credit_card(self) -> None:
        # Valid Visa test number
        content = "Card: 4532015112830366"
        matches = detect_credit_card(content)

        assert len(matches) == 1
        assert matches[0]["type"] == "credit_card"
        assert matches[0]["value"] == "4532015112830366"

    def test_detect_credit_card_with_spaces(self) -> None:
        # Valid Mastercard test number
        # Add spaces
        spaced_content = "Card: 5425 2334 3010 9903"
        matches = detect_credit_card(spaced_content)

        assert len(matches) == 1
        assert "5425 2334 3010 9903" in matches[0]["value"]

    def test_detect_credit_card_with_dashes(self) -> None:
        content = "Card: 4532-0151-1283-0366"
        matches = detect_credit_card(content)

        assert len(matches) == 1

    def test_invalid_luhn_not_detected(self) -> None:
        # Invalid Luhn checksum
        content = "Card: 1234567890123456"
        matches = detect_credit_card(content)
        assert len(matches) == 0

    def test_no_credit_card(self) -> None:
        content = "No cards here."
        matches = detect_credit_card(content)
        assert len(matches) == 0

Frequently Asked Questions

What is the TestCreditCardDetection class?
TestCreditCardDetection is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is TestCreditCardDetection defined?
TestCreditCardDetection is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 61.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free