コード例 #1
0
def test_check_provider_is_active(
        mocker, fake_uuid, is_active, notification_type, checked_notification_type, expected_result
):
    mocked_provider_details = mocker.Mock(ProviderDetails)
    mocked_provider_details.active = is_active
    mocked_provider_details.notification_type = notification_type
    mocker.patch(
        PROVIDER_DETAILS_BY_ID_PATH,
        return_value=mocked_provider_details
    )
    assert is_provider_valid(fake_uuid, checked_notification_type) is expected_result
コード例 #2
0
 def validate_type(self, data):
     if data.get('template_type') in [
             models.EMAIL_TYPE, models.LETTER_TYPE
     ]:
         subject = data.get('subject')
         if not subject or subject.strip() == '':
             raise ValidationError('Invalid template subject', 'subject')
     provider_id = data.get('provider_id')
     if provider_id is not None and not validate_providers.is_provider_valid(
             provider_id, data.get('template_type')):
         raise ValidationError(f"Invalid provider id: {provider_id}",
                               'provider_id')
コード例 #3
0
 def validate_sms_provider_id(self, value):
     if value and not validate_providers.is_provider_valid(value, SMS_TYPE):
         raise ValidationError(f"Invalid sms_provider_id: {value}")
コード例 #4
0
 def validate_email_provider_id(self, value):
     if value and not validate_providers.is_provider_valid(
             value, EMAIL_TYPE):
         raise ValidationError(f"Invalid email_provider_id: {value}")
コード例 #5
0
def test_check_provider_exists(notify_db, fake_uuid):
    assert is_provider_valid(fake_uuid, EMAIL_TYPE) is False