def test_sms_sender_form_validation(
    client,
    mock_get_user_by_email,
):
    form = ServiceSmsSenderForm()

    form.sms_sender.data = 'elevenchars'
    form.validate()
    assert not form.errors

    form.sms_sender.data = ''
    form.validate()
    assert "Can’t be empty" == form.errors['sms_sender'][0]

    form.sms_sender.data = 'morethanelevenchars'
    form.validate()
    assert "Enter 11 characters or fewer" == form.errors['sms_sender'][0]

    form.sms_sender.data = '###########'
    form.validate()
    assert 'Use letters and numbers only' == form.errors['sms_sender'][0]
def test_sms_sender_form_validation(
    client,
    mock_get_user_by_email,
):
    form = ServiceSmsSenderForm()

    form.sms_sender.data = 'elevenchars'
    form.validate()
    assert not form.errors

    form.sms_sender.data = ''
    form.validate()
    assert "This cannot be empty" == form.errors['sms_sender'][0]

    form.sms_sender.data = 'morethanelevenchars'
    form.validate()
    assert "Enter 11 characters or fewer" == form.errors['sms_sender'][0]

    form.sms_sender.data = '###########'
    form.validate()
    assert 'Use letters and numbers only' == form.errors['sms_sender'][0]

    form.sms_sender.data = '333'
    form.validate()
    assert 'Enter 4 characters or more' == form.errors['sms_sender'][0]

    form.sms_sender.data = '4444'
    form.validate()
    assert not form.errors

    form.sms_sender.data = '00111222333'
    form.validate()
    assert "Can't start with 00" == form.errors['sms_sender'][0]
def test_sms_sender_form_validation(
    client,
    mock_get_user_by_email,
):
    form = ServiceSmsSenderForm()

    form.sms_sender.data = "elevenchars"
    form.validate()
    assert not form.errors

    form.sms_sender.data = ""
    form.validate()
    assert "This cannot be empty" == form.errors["sms_sender"][0]

    form.sms_sender.data = "morethanelevenchars"
    form.validate()
    assert "Enter 11 characters or fewer" == form.errors["sms_sender"][0]

    form.sms_sender.data = "###########"
    form.validate()
    assert "Use letters and numbers only" == form.errors["sms_sender"][0]

    form.sms_sender.data = "333"
    form.validate()
    assert "Enter 4 characters or more" == form.errors["sms_sender"][0]

    form.sms_sender.data = "4444"
    form.validate()
    assert not form.errors

    form.sms_sender.data = "00111222333"
    form.validate()
    assert "Can't start with 00" == form.errors["sms_sender"][0]
def test_sms_sender_form_validation(
    client,
    mock_get_user_by_email,
):
    form = ServiceSmsSenderForm()

    form.sms_sender.data = 'elevenchars'
    form.validate()
    assert not form.errors

    form.sms_sender.data = ''
    form.validate()
    assert "Cannot be empty" == form.errors['sms_sender'][0]

    form.sms_sender.data = 'morethanelevenchars'
    form.validate()
    assert "Enter 11 characters or fewer" == form.errors['sms_sender'][0]

    form.sms_sender.data = '###########'
    form.validate()
    assert 'Use letters and numbers only' == form.errors['sms_sender'][0]

    # Underscores are allowed
    form.sms_sender.data = 'UK_GOV'
    form.validate()
    assert not form.errors

    # Full stops are allowed
    form.sms_sender.data = 'UK.GOV'
    form.validate()
    assert not form.errors

    form.sms_sender.data = '22'
    form.validate()
    assert 'Enter 3 characters or more' == form.errors['sms_sender'][0]

    form.sms_sender.data = '333'
    form.validate()
    assert not form.errors

    form.sms_sender.data = '00111222333'
    form.validate()
    assert "Cannot start with 00" == form.errors['sms_sender'][0]