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
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')
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}")
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}")
def test_check_provider_exists(notify_db, fake_uuid): assert is_provider_valid(fake_uuid, EMAIL_TYPE) is False