<commit_before><commit_msg>add testcase in mod_mailer<commit_after>#
# Newfies-Dialer License
# http://www.newfies-dialer.org
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (C) 2011-2014 Star2Billing S.L.
#
# The Initial Developer of the Original Code is
# <NAME> <<EMAIL>>
#

#from django.test import TestCase
#from django.contrib.auth.models import User
#from django.conf import settings
from common.utils import BaseAuthenticatedClient


class ModMailerAdminView(BaseAuthenticatedClient):
    """
    Test cases for mail MailTemplate list Admin Interface.
    """

    def test_admin_mail_template_view_list(self):
        """Test Function to check admin MailTemplate list"""
        response = self.client.get("/admin/mod_mailer/mailtemplate/")
        self.failUnlessEqual(response.status_code, 200)

    def test_admin_mail_template_view_add(self):
        """Test Function to check admin MailTemplate add"""
        response = self.client.get("/admin/mod_mailer/mailtemplate/add/")
        self.assertEqual(response.status_code, 200)
        response = self.client.post(
            '/admin/mod_mailer/mailtemplate/add/',
            data={'label': 'test', 'template_key': 'template_key_xyz',
                  'from_email': '<EMAIL>', 'from_name': 'xyz',
                  'subject': 'sample_template', 'message_plaintext': 'test msg',
                  'message_html': '<b>test msg</b>'}, follow=True)
        self.assertEqual(response.status_code, 200)

    def test_admin_mailspooler_view_list(self):
        """Test Function to check admin mailspooler list"""
        response = self.client.get("/admin/mod_mailer/mailspooler/")
        self.failUnlessEqual(response.status_code, 200)

    def test_admin_mailspooler_view_add(self):
        """Test Function to check admin mailspooler add"""
        response = self.client.get("/admin/mod_mailer/mailspooler/add/")
        self.assertEqual(response.status_code, 200)
        response = self.client.post(
            '/admin/mod_mailer/mailspooler/add/',
            data={'mailtemplate': '1', 'contact_email': '<EMAIL>',
                  'parameter': '', 'mailspooler_type': '1'},
            follow=True)
        self.assertEqual(response.status_code, 200)
{'fraction_non_alphanumeric': 0.12185929648241206, 'fraction_numerical': 0.013819095477386936, 'mean_word_length': 3.2283185840707964, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2732222', 'n_tokens_mistral': 747, 'n_tokens_neox': 706, 'n_words': 169}