thunderbird_accounts.mail.tests.test_utils

Classes

CreateStalwartAccountTestCase([methodName])

create_stalwart_account should seed the Stalwart description with the user's display name.

IsAddressTakenTestCase([methodName])

ValidateEmailTestCase([methodName])

Tests for validate_email, focused on the local-part length check.

class thunderbird_accounts.mail.tests.test_utils.ValidateEmailTestCase(methodName='runTest')[source]

Bases: TestCase

Tests for validate_email, focused on the local-part length check.

USERNAME_MIN_LENGTH = 3 → local parts shorter than 3 chars are rejected USERNAME_MAX_LENGTH = 150 → local parts longer than 150 chars are rejected

test_local_part_at_min_length_is_valid()[source]

A local part of exactly USERNAME_MIN_LENGTH (3) characters is accepted.

test_local_part_one_below_min_raises()[source]

A local part of USERNAME_MIN_LENGTH - 1 (2) characters is rejected.

test_local_part_single_char_raises()[source]

A single-character local part is rejected.

test_empty_local_part_raises()[source]

An empty local part (length 0) is rejected.

test_local_part_at_max_length_is_valid()[source]

A local part of exactly USERNAME_MAX_LENGTH (150) characters is accepted.

test_local_part_above_max_raises()[source]

A local part longer than USERNAME_MAX_LENGTH (150) is rejected.

test_missing_at_sign_raises()[source]

An email without ‘@’ is rejected before the length check.

test_invalid_email_format_raises()[source]

A string with ‘@’ but an otherwise invalid format is rejected.

test_valid_email_returns_true()[source]

A well-formed email within length bounds returns True.

test_custom_error_message_is_used()[source]

The caller-supplied error_message is propagated in the exception.

test_min_length_override_allows_short_local_part()[source]

Callers can lower the minimum below USERNAME_MIN_LENGTH.

test_min_length_override_still_rejects_below_override()[source]

The overridden minimum is still enforced.

class thunderbird_accounts.mail.tests.test_utils.CreateStalwartAccountTestCase(methodName='runTest')[source]

Bases: TestCase

create_stalwart_account should seed the Stalwart description with the user’s display name.

class thunderbird_accounts.mail.tests.test_utils.IsAddressTakenTestCase(methodName='runTest')[source]

Bases: TestCase

test_success()

If no one is using the address then it’s not ‘taken’.

test_fail_due_to_user()

Ensure that if a user is using that address, that it will be ‘taken’.

test_fail_due_to_email_alias()

Ensure that if an email alias exists of that address, that it will be ‘taken’.

test_fail_due_to_stalwart()[source]

Same as the other fail tests but we test both with the waffle switch off (return false) and switch on (return true)

test_check_remote_false_skips_stalwart_lookup()

Even with the switch on, check_remote=False must not hit Stalwart.

test_stalwart_account_not_found_is_not_taken()

A clean AccountNotFoundError from Stalwart means the address is free.

test_stalwart_invalid_jmap_response_is_treated_as_taken()

If we can’t parse Stalwart’s response we can’t prove the address is free, so treat it as taken.