<commit_before># coding: utf-8
from django.core.urlresolvers import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from .utils import utils
from django.db import transaction
from desecapi.models import Domain
from django.core import mail
import httpretty
from django.conf import settings


class UnsuccessfulDonationTests(APITestCase):
    def testExpectUnauthorizedOnGet(self):
        url = reverse('donation')
        response = self.client.get(url, format='json')
        self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

    def testExpectUnauthorizedOnPut(self):
        url = reverse('donation')
        response = self.client.put(url, format='json')
        self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

    def testExpectUnauthorizedOnDelete(self):
        url = reverse('donation')
        response = self.client.delete(url, format='json')
        self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)


class SuccessfulDonationTests(APITestCase):
    def testCanPostDonations(self):
        url = reverse('donation')
        data = \
            {
                'name': '<NAME> 马大为',
                'iban': 'DE89370400440532013000',
                'bic': 'BYLADEM1SWU',
                'amount': 123.45,
                'message': 'hi there, thank you. Also, some random chars:  ™ • ½ ¼ ¾ ⅓ ⅔ † ‡ µ ¢ £ € « » ♤ ♧ ♥ ♢ ¿ ',
                'email': '<EMAIL>',
            }
        response = self.client.post(url, data)
        email_internal = str(mail.outbox[0].message())
        direct_debit = str(mail.outbox[0].attachments[0][1])
        email_external = str(mail.outbox[1].message())
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(len(mail.outbox), 2)
        self.assertEqual(response.data['iban'], 'DE8937xxx')
        self.assertTrue('Komplizierter Vornamu' in direct_debit)
        self.assertTrue(data['iban'] in email_internal)<commit_msg>fix(tests): add test and removed unused variable<commit_after># coding: utf-8
from django.core.urlresolvers import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from .utils import utils
from django.db import transaction
from desecapi.models import Domain
from django.core import mail
import httpretty
from django.conf import settings


class UnsuccessfulDonationTests(APITestCase):
    def testExpectUnauthorizedOnGet(self):
        url = reverse('donation')
        response = self.client.get(url, format='json')
        self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

    def testExpectUnauthorizedOnPut(self):
        url = reverse('donation')
        response = self.client.put(url, format='json')
        self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

    def testExpectUnauthorizedOnDelete(self):
        url = reverse('donation')
        response = self.client.delete(url, format='json')
        self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)


class SuccessfulDonationTests(APITestCase):
    def testCanPostDonations(self):
        url = reverse('donation')
        data = \
            {
                'name': '<NAME>',
                'iban': 'DE89370400440532013000',
                'bic': 'BYLADEM1SWU',
                'amount': 123.45,
                'message': 'hi there, thank you. Also, some random chars:  ™ • ½ ¼ ¾ ⅓ ⅔ † ‡ µ ¢ £ € « » ♤ ♧ ♥ ♢ ¿ ',
                'email': '<EMAIL>',
            }
        response = self.client.post(url, data)
        self.assertTrue(len(mail.outbox) > 0)
        email_internal = str(mail.outbox[0].message())
        direct_debit = str(mail.outbox[0].attachments[0][1])
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(len(mail.outbox), 2)
        self.assertEqual(response.data['iban'], 'DE8937xxx')
        self.assertTrue('Komplizierter Vornamu' in direct_debit)
        self.assertTrue(data['iban'] in email_internal)
{'fraction_non_alphanumeric': 0.11233480176211454, 'fraction_numerical': 0.023984336759667158, 'mean_word_length': 3.087, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1865563', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1234, 'n_words': 274}