<commit_before># -*- config: utf-8 -*-

import unittest

def obj(**args):
    return type('<anonymous object>', (object,), args)()

class TestSMTPNotifier(unittest.TestCase):
    def setUp(self):
        import urllib2

        from datetime import date, datetime, time
        from seminarnotifier.notifier import Notifier
        from seminarnotifier.seminar import Seminar

        self.now = datetime.now()

        self.config = {
                'subject': 'Seminar {0} on %B %d',
                'message': 'Seminar {0} on %B %d %H:%M at {2}: \n{1}',
                'host': 'localhost',
                'port': 25,
                'from': '<<EMAIL>>',
                'to': ['<<EMAIL>>'],
                }

        self.notifier = Notifier.get('SMTPNotifier', self.config)

        self.seminar = Seminar('title', date(2015, 4, 15), time(9, 15), 'A111', ['Foo', 'Bar', 'Baz'])

    def test_find_header(self):
        calls = dict()
        class MockSMTP:
            def __init__(*args):
                calls['__init__'] = list(args);
            
            def sendmail(*args):
                calls['sendmail'] = list(args);

            def quit(*args):
                calls['quit'] = list(args);

        import smtplib
        from base64 import b64decode

        smtplib.SMTP = MockSMTP

        self.notifier.notify(self.seminar)

        self.assertEqual(calls['__init__'][1:], ['localhost', 25]);
        self.assertEqual(calls['sendmail'][1:3], ['<<EMAIL>>', ['<<EMAIL>>']]);

        message = calls['sendmail'][3]
        message_body = b64decode(message.split('\n\n')[1].strip())
        self.assertEqual(message_body, 'Seminar title on April 15 09:15 at A111: \nFoo\nBar\nBaz'.encode('UTF-8'))

        self.assertEqual(calls['quit'][1:], []);

<commit_msg>Fix test case<commit_after># -*- config: utf-8 -*-

import unittest

def obj(**args):
    return type('<anonymous object>', (object,), args)()

class TestSMTPNotifier(unittest.TestCase):
    def setUp(self):
        import urllib2

        from datetime import date, datetime, time
        from seminarnotifier.notifier import Notifier
        from seminarnotifier.seminar import Seminar

        self.now = datetime.now()

        self.config = {
                'subject': 'Seminar {0} on %B %d',
                'message': 'Seminar {0} on %B %d %H:%M at {2}: \n{1}',
                'host': 'localhost',
                'port': 25,
                'from': '<<EMAIL>>',
                'to': ['<<EMAIL>>'],
                }

        self.notifier = Notifier.get('SMTPNotifier', self.config)

        self.seminar = Seminar('title', date(2015, 4, 15), time(9, 15), 'A111', ['Foo', 'Bar', 'Baz'])

    def test_find_header(self):
        calls = dict()
        class MockSMTP:
            def __init__(*args):
                calls['__init__'] = list(args);
            
            def sendmail(*args):
                calls['sendmail'] = list(args);

            def quit(*args):
                calls['quit'] = list(args);

        import smtplib
        from base64 import b64decode

        smtplib.SMTP = MockSMTP

        self.notifier.notify(self.seminar)

        self.assertEqual(calls['__init__'][1:], ['localhost', 25]);
        self.assertEqual(calls['sendmail'][1:3], ['<<EMAIL>>', ['<<EMAIL>>']]);

        message = calls['sendmail'][3]
        message_body = b64decode(message.split('\n\n')[1].strip())
        self.assertEqual(message_body, 'Seminar title on April 15 09:15 at A111: \n  Foo\n  Bar\n  Baz'.encode('UTF-8'))

        self.assertEqual(calls['quit'][1:], []);


{'fraction_non_alphanumeric': 0.1664804469273743, 'fraction_numerical': 0.025139664804469275, 'mean_word_length': 2.1275109170305675, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1041725', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1114, 'n_words': 247}