コード例 #1
0
def test_anonymize_as_numbers_ignore_sub_numbers(raw_line,
                                                 sensitive_as_numbers):
    """Test that matching 'AS numbers' within other numbers are not replaced."""
    anonymizer_as_number = AsNumberAnonymizer(sensitive_as_numbers, SALT)

    line = raw_line.format(*sensitive_as_numbers)
    anon_line = anonymize_as_numbers(anonymizer_as_number, line)

    # Make sure substrings of other numbers are not affected
    assert anon_line == line
コード例 #2
0
def test_anonymize_as_numbers(raw_line, sensitive_as_numbers):
    """Test anonymization of lines with AS numbers."""
    anonymizer_as_number = AsNumberAnonymizer(sensitive_as_numbers, SALT)

    line = raw_line.format(*sensitive_as_numbers)
    anon_line = anonymize_as_numbers(anonymizer_as_number, line)

    # Anonymize each AS number individually & build another anon line
    anon_numbers = [
        anonymize_as_numbers(anonymizer_as_number, number)
        for number in sensitive_as_numbers
    ]
    individually_anon_line = raw_line.format(*anon_numbers)

    # Make sure anonymizing each number individually gives the same result as anonymizing all at once
    assert anon_line == individually_anon_line

    for as_number in sensitive_as_numbers:
        # Make sure all AS numbers are removed from the line
        assert as_number not in anon_line