# 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
             % (expected, response.status_code, feedback_url))
        self.assertContains(response, 'here was an error sending your feedback',
            msg_prefix='response should display error message when sending email triggers an exception',
            status_code=500)

    def test_request_materials(self):
        # NOTE: this is a test for request_materials page
        # The PT ID is #117174547

        # GET - display the form
        rqst_materials_url = reverse('content:request-materials')
        response = self.client.get(rqst_materials_url)
        expected = 200
        self.assertEqual(response.status_code, expected,
            'Expected %s but returned %s for GET on %s'
             % (expected, response.status_code, rqst_materials_url))

        '''Check if the MARBL archive has two contacts'''
        self.assertEqual(Archive.objects.get(label="MARBL").contacts.count(), 2)

        '''Check if the EUA archive has two contacts'''
        self.assertEqual(Archive.objects.get(label="EUA").contacts.count(), 3)

        '''Check if the Pitts archive has zero contacts'''
        self.assertEqual(Archive.objects.get(label="Pitts").contacts.count(), 0)

        '''Check if the MARBL contains the contact name "test1"'''
        self.assertEqual(Archive.objects.get(label="MARBL").contacts.filter(username="test1").count(), 1)

        '''Check if the EUA contains the contact name "test2"'''

# 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

             % (expected, response.status_code, feedback_url))
        self.assertContains(response, 'here was an error sending your feedback',
            msg_prefix='response should display error message when sending email triggers an exception',
            status_code=500)

    def test_request_materials(self):
        # NOTE: this is a test for request_materials page
        # The PT ID is #117174547

        # GET - display the form
        rqst_materials_url = reverse('content:request-materials')
        response = self.client.get(rqst_materials_url)
        expected = 200
        self.assertEqual(response.status_code, expected,
            'Expected %s but returned %s for GET on %s'
             % (expected, response.status_code, rqst_materials_url))

        '''Check if the MARBL archive has two contacts'''
        self.assertEqual(Archive.objects.get(label="MARBL").contacts.count(), 2)

        '''Check if the EUA archive has two contacts'''
        self.assertEqual(Archive.objects.get(label="EUA").contacts.count(), 3)

        '''Check if the Pitts archive has zero contacts'''
        self.assertEqual(Archive.objects.get(label="Pitts").contacts.count(), 0)

        '''Check if the MARBL contains the contact name "test1"'''
        self.assertEqual(Archive.objects.get(label="MARBL").contacts.filter(username="test1").count(), 1)

        '''Check if the EUA contains the contact name "test2"'''

        self.assertEqual(Archive.objects.get(label="EUA").contacts.filter(username="test2").count(), 1)