# Path: findingaids/content/forms.py
# class FeedbackForm(forms.Form):
# class RequestMaterialsForm(forms.Form):
#     def __init__(self, data=None, remote_ip=None, **kwargs):
#     def send_email(self):
# def generate_from_email(data):
#     def send_email(self):
# 
# Path: findingaids/fa/models.py
# class Archive(models.Model):
#     '''Model to define Archives associated with EAD documents, for use with
#     admin user permissions and to identify subversion repositories where
#     content will be published from.'''
#     label = models.CharField(max_length=10,
#         help_text='Short label to identify an archive')
#     name = models.CharField(max_length=255,
#         help_text='repository name (subarea) in EAD to identify finding aids associated with this archive')
#     svn = models.URLField('Subversion Repository',
#         help_text='URL to subversion repository containing EAD for this archive')
#     slug = models.SlugField(help_text='''shorthand id
#         (auto-generated from label; do not modify after initial archive definition)''')
#     contacts = models.ManyToManyField(settings.AUTH_USER_MODEL,
#         help_text='Contact person for display on the Request Materials page (email required)',
#         blank=True)
# 
# 
#     def __unicode__(self):
#         return self.label
# 
#     @property
#     def svn_local_path(self):
#         return os.path.join(settings.SVN_WORKING_DIR, self.slug)
# 
#     def contact_names(self):
#         '''List of contact names method for display in django admin list
#         display.  Shows email if user has no full name.'''
#         return ', '.join([contact.get_full_name() or contact.email
#                           for contact in self.contacts.all()])
#     contact_names.short_description = "Contacts"


from os import path
from unittest import skip
from django.test import Client
from django.conf import settings
from django.core.urlresolvers import reverse
from eulexistdb.testutil import TestCase as EulexistdbTestCase
from eullocal.django.forms.tests import MockCaptcha
from findingaids.content import forms
from findingaids.fa.models import Archive
    'fa', 'tests', 'fixtures')


class EmailTestCase(EulexistdbTestCase):
    # Common test class with logic to mock sending mail and mock captcha submission
    # to test functionality without actual sending email or querying captcha servers.
    # Extending EulDjangoTestCase to allow use of eXist fixtures
    server_email = 'admin@findingaids.library.emory.edu'
    email_prefix = '[FA] '
    feedback_email = ('fa-admin@emory.edu',)
    _sent_mail = {}
    _mail_exception = None

    @property
    def sent_mail(self):
        'Access parameters passed to last send_mail call'
        return EmailTestCase._sent_mail

    def simulate_email_exception(self):
        'Simulate an exception on the next send_mail call via mock send_mail'
        EmailTestCase._mail_exception = Exception

    @staticmethod
    def _mock_send_mail(subject, message, from_email, recipient_list, **kwargs):
        if EmailTestCase._mail_exception is not None:
            ex = EmailTestCase._mail_exception
            EmailTestCase._mail_exception = None
            raise ex

        # store values for tests to inspect

# Path: findingaids/content/forms.py
# class FeedbackForm(forms.Form):
# class RequestMaterialsForm(forms.Form):
#     def __init__(self, data=None, remote_ip=None, **kwargs):
#     def send_email(self):
# def generate_from_email(data):
#     def send_email(self):
# 
# Path: findingaids/fa/models.py
# class Archive(models.Model):
#     '''Model to define Archives associated with EAD documents, for use with
#     admin user permissions and to identify subversion repositories where
#     content will be published from.'''
#     label = models.CharField(max_length=10,
#         help_text='Short label to identify an archive')
#     name = models.CharField(max_length=255,
#         help_text='repository name (subarea) in EAD to identify finding aids associated with this archive')
#     svn = models.URLField('Subversion Repository',
#         help_text='URL to subversion repository containing EAD for this archive')
#     slug = models.SlugField(help_text='''shorthand id
#         (auto-generated from label; do not modify after initial archive definition)''')
#     contacts = models.ManyToManyField(settings.AUTH_USER_MODEL,
#         help_text='Contact person for display on the Request Materials page (email required)',
#         blank=True)
# 
# 
#     def __unicode__(self):
#         return self.label
# 
#     @property
#     def svn_local_path(self):
#         return os.path.join(settings.SVN_WORKING_DIR, self.slug)
# 
#     def contact_names(self):
#         '''List of contact names method for display in django admin list
#         display.  Shows email if user has no full name.'''
#         return ', '.join([contact.get_full_name() or contact.email
#                           for contact in self.contacts.all()])
#     contact_names.short_description = "Contacts"


# Path: findingaids/content/tests.py
from os import path
from unittest import skip
from django.test import Client
from django.conf import settings
from django.core.urlresolvers import reverse
from eulexistdb.testutil import TestCase as EulexistdbTestCase
from eullocal.django.forms.tests import MockCaptcha
from findingaids.content import forms
from findingaids.fa.models import Archive

    'fa', 'tests', 'fixtures')


class EmailTestCase(EulexistdbTestCase):
    # Common test class with logic to mock sending mail and mock captcha submission
    # to test functionality without actual sending email or querying captcha servers.
    # Extending EulDjangoTestCase to allow use of eXist fixtures
    server_email = 'admin@findingaids.library.emory.edu'
    email_prefix = '[FA] '
    feedback_email = ('fa-admin@emory.edu',)
    _sent_mail = {}
    _mail_exception = None

    @property
    def sent_mail(self):
        'Access parameters passed to last send_mail call'
        return EmailTestCase._sent_mail

    def simulate_email_exception(self):
        'Simulate an exception on the next send_mail call via mock send_mail'
        EmailTestCase._mail_exception = Exception

    @staticmethod
    def _mock_send_mail(subject, message, from_email, recipient_list, **kwargs):
        if EmailTestCase._mail_exception is not None:
            ex = EmailTestCase._mail_exception
            EmailTestCase._mail_exception = None
            raise ex

        # store values for tests to inspect

        EmailTestCase._sent_mail = {'subject': subject, 'message': message,