Blame tests/test_pagure_lib_notify.py

Pierre-Yves Chibon fd2f9e
# -*- coding: utf-8 -*-
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
"""
Pierre-Yves Chibon fd2f9e
 (c) 2016 - Copyright Red Hat Inc
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
 Authors:
Pierre-Yves Chibon fd2f9e
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
"""
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
__requires__ = ['SQLAlchemy >= 0.8']
Pierre-Yves Chibon fd2f9e
import pkg_resources
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
import unittest
Pierre-Yves Chibon fd2f9e
import shutil
Pierre-Yves Chibon fd2f9e
import sys
Pierre-Yves Chibon fd2f9e
import os
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon 33ff8d
from mock import patch, MagicMock
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
sys.path.insert(0, os.path.join(os.path.dirname(
Pierre-Yves Chibon fd2f9e
    os.path.abspath(__file__)), '..'))
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
import pagure.lib
Pierre-Yves Chibon fd2f9e
import pagure.lib.model
Pierre-Yves Chibon fd2f9e
import pagure.lib.notify
Pierre-Yves Chibon fd2f9e
import tests
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
class PagureLibNotifytests(tests.Modeltests):
Pierre-Yves Chibon fd2f9e
    """ Tests for pagure.lib.notify """
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
    def test_get_emails_for_obj_issue(self):
Pierre-Yves Chibon fd2f9e
        """ Test the _get_emails_for_obj method from pagure.lib.notify. """
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Create the project ns/test
Pierre-Yves Chibon fd2f9e
        item = pagure.lib.model.Project(
Pierre-Yves Chibon fd2f9e
            user_id=1,  # pingou
Pierre-Yves Chibon fd2f9e
            name='test3',
Pierre-Yves Chibon fd2f9e
            namespace='ns',
Pierre-Yves Chibon fd2f9e
            description='test project #1',
Pierre-Yves Chibon fd2f9e
            hook_token='aaabbbcccdd',
Pierre-Yves Chibon fd2f9e
        )
Pierre-Yves Chibon fd2f9e
        item.close_status = ['Invalid', 'Insufficient data', 'Fixed']
Pierre-Yves Chibon fd2f9e
        self.session.add(item)
Pierre-Yves Chibon fd2f9e
        self.session.commit()
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Create the ticket
Pierre-Yves Chibon fd2f9e
        iss = pagure.lib.new_issue(
Pierre-Yves Chibon fd2f9e
            issue_id=4,
Pierre-Yves Chibon fd2f9e
            session=self.session,
Pierre-Yves Chibon fd2f9e
            repo=item,
Pierre-Yves Chibon fd2f9e
            title='test issue',
Pierre-Yves Chibon fd2f9e
            content='content test issue',
Pierre-Yves Chibon fd2f9e
            user='pingou',
Pierre-Yves Chibon fd2f9e
            ticketfolder=None,
Pierre-Yves Chibon fd2f9e
        )
Pierre-Yves Chibon fd2f9e
        self.session.commit()
Pierre-Yves Chibon fd2f9e
        self.assertEqual(iss.id, 4)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(iss.title, 'test issue')
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        exp = set(['bar@pingou.com'])
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.notify._get_emails_for_obj(iss)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, exp)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Comment on the ticket
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.add_issue_comment(
Pierre-Yves Chibon fd2f9e
            self.session,
Pierre-Yves Chibon fd2f9e
            issue=iss,
Pierre-Yves Chibon fd2f9e
            comment='This is a comment',
Pierre-Yves Chibon fd2f9e
            user='foo',
Pierre-Yves Chibon fd2f9e
            ticketfolder=None,
Pierre-Yves Chibon fd2f9e
            notify=False)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, 'Comment added')
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        exp = set(['bar@pingou.com', 'foo@bar.com'])
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.notify._get_emails_for_obj(iss)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, exp)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Create user `bar`
Pierre-Yves Chibon fd2f9e
        item = pagure.lib.model.User(
Pierre-Yves Chibon fd2f9e
            user='bar',
Pierre-Yves Chibon fd2f9e
            fullname='bar name',
Pierre-Yves Chibon fd2f9e
            password='bar',
Pierre-Yves Chibon fd2f9e
            default_email='bar@bar.com',
Pierre-Yves Chibon fd2f9e
        )
Pierre-Yves Chibon fd2f9e
        self.session.add(item)
Pierre-Yves Chibon fd2f9e
        item = pagure.lib.model.UserEmail(
Pierre-Yves Chibon fd2f9e
            user_id=3,
Pierre-Yves Chibon fd2f9e
            email='bar@bar.com')
Pierre-Yves Chibon fd2f9e
        self.session.add(item)
Pierre-Yves Chibon fd2f9e
        self.session.commit()
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Watch the ticket
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.set_watch_obj(self.session, 'bar', iss, True)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, 'You are now watching this issue')
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        exp = set(['bar@pingou.com', 'foo@bar.com', 'bar@bar.com'])
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.notify._get_emails_for_obj(iss)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, exp)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon c8242b
    def test_get_emails_for_obj_issue_watching_project(self):
Pierre-Yves Chibon c8242b
        """ Test the _get_emails_for_obj method from pagure.lib.notify. """
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Create the project ns/test
Pierre-Yves Chibon c8242b
        item = pagure.lib.model.Project(
Pierre-Yves Chibon c8242b
            user_id=1,  # pingou
Pierre-Yves Chibon c8242b
            name='test3',
Pierre-Yves Chibon c8242b
            namespace='ns',
Pierre-Yves Chibon c8242b
            description='test project #1',
Pierre-Yves Chibon c8242b
            hook_token='aaabbbcccdd',
Pierre-Yves Chibon c8242b
        )
Pierre-Yves Chibon c8242b
        item.close_status = ['Invalid', 'Insufficient data', 'Fixed']
Pierre-Yves Chibon c8242b
        self.session.add(item)
Pierre-Yves Chibon c8242b
        self.session.commit()
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Create the ticket
Pierre-Yves Chibon c8242b
        iss = pagure.lib.new_issue(
Pierre-Yves Chibon c8242b
            issue_id=4,
Pierre-Yves Chibon c8242b
            session=self.session,
Pierre-Yves Chibon c8242b
            repo=item,
Pierre-Yves Chibon c8242b
            title='test issue',
Pierre-Yves Chibon c8242b
            content='content test issue',
Pierre-Yves Chibon c8242b
            user='pingou',
Pierre-Yves Chibon c8242b
            ticketfolder=None,
Pierre-Yves Chibon c8242b
        )
Pierre-Yves Chibon c8242b
        self.session.commit()
Pierre-Yves Chibon c8242b
        self.assertEqual(iss.id, 4)
Pierre-Yves Chibon c8242b
        self.assertEqual(iss.title, 'test issue')
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        exp = set(['bar@pingou.com'])
Pierre-Yves Chibon c8242b
        out = pagure.lib.notify._get_emails_for_obj(iss)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, exp)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Comment on the ticket
Pierre-Yves Chibon c8242b
        out = pagure.lib.add_issue_comment(
Pierre-Yves Chibon c8242b
            self.session,
Pierre-Yves Chibon c8242b
            issue=iss,
Pierre-Yves Chibon c8242b
            comment='This is a comment',
Pierre-Yves Chibon c8242b
            user='foo',
Pierre-Yves Chibon c8242b
            ticketfolder=None,
Pierre-Yves Chibon c8242b
            notify=False)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, 'Comment added')
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        exp = set(['bar@pingou.com', 'foo@bar.com'])
Pierre-Yves Chibon c8242b
        out = pagure.lib.notify._get_emails_for_obj(iss)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, exp)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Create user `bar`
Pierre-Yves Chibon c8242b
        item = pagure.lib.model.User(
Pierre-Yves Chibon c8242b
            user='bar',
Pierre-Yves Chibon c8242b
            fullname='bar name',
Pierre-Yves Chibon c8242b
            password='bar',
Pierre-Yves Chibon c8242b
            default_email='bar@bar.com',
Pierre-Yves Chibon c8242b
        )
Pierre-Yves Chibon c8242b
        self.session.add(item)
Pierre-Yves Chibon c8242b
        item = pagure.lib.model.UserEmail(
Pierre-Yves Chibon c8242b
            user_id=3,
Pierre-Yves Chibon c8242b
            email='bar@bar.com')
Pierre-Yves Chibon c8242b
        self.session.add(item)
Pierre-Yves Chibon c8242b
        self.session.commit()
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Watch the project
Farhaan Bukhsh 481209
        repo = pagure.get_authorized_project(self.session, 'test3', namespace='ns')
Matt Prahl b49f93
        out = pagure.lib.update_watch_status(self.session, repo, 'bar', '1')
Matt Prahl b49f93
        self.assertEqual(
Pierre-Yves Chibon d7ac66
            out, 'You are now watching issues and PRs on this project')
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        exp = set(['bar@pingou.com', 'foo@bar.com', 'bar@bar.com'])
Pierre-Yves Chibon c8242b
        out = pagure.lib.notify._get_emails_for_obj(iss)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, exp)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon 33ff8d
    @patch('pagure.lib.notify.smtplib.SMTP')
Pierre-Yves Chibon 33ff8d
    def test_get_emails_for_obj_pr(self, mock_smtp):
Pierre-Yves Chibon fd2f9e
        """ Test the _get_emails_for_obj method from pagure.lib.notify. """
Pierre-Yves Chibon 33ff8d
        mock_smtp.return_value = MagicMock()
Pierre-Yves Chibon 33ff8d
Pierre-Yves Chibon fd2f9e
        tests.create_projects(self.session)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Create the project ns/test
Pierre-Yves Chibon fd2f9e
        item = pagure.lib.model.Project(
Pierre-Yves Chibon fd2f9e
            user_id=1,  # pingou
Pierre-Yves Chibon fd2f9e
            name='test3',
Pierre-Yves Chibon fd2f9e
            namespace='ns',
Pierre-Yves Chibon fd2f9e
            description='test project #1',
Pierre-Yves Chibon fd2f9e
            hook_token='aaabbbcccdd',
Pierre-Yves Chibon fd2f9e
        )
Pierre-Yves Chibon fd2f9e
        item.close_status = ['Invalid', 'Insufficient data', 'Fixed']
Pierre-Yves Chibon fd2f9e
        self.session.add(item)
Pierre-Yves Chibon fd2f9e
        self.session.commit()
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Create the PR
Farhaan Bukhsh 83f8bc
        repo = pagure.lib._get_project(self.session, 'test')
Pierre-Yves Chibon fd2f9e
        req = pagure.lib.new_pull_request(
Pierre-Yves Chibon fd2f9e
            session=self.session,
Pierre-Yves Chibon fd2f9e
            repo_from=repo,
Pierre-Yves Chibon fd2f9e
            branch_from='master',
Pierre-Yves Chibon fd2f9e
            repo_to=repo,
Pierre-Yves Chibon fd2f9e
            branch_to='master',
Pierre-Yves Chibon fd2f9e
            title='test pull-request',
Pierre-Yves Chibon fd2f9e
            user='pingou',
Pierre-Yves Chibon fd2f9e
            requestfolder=None,
Pierre-Yves Chibon fd2f9e
        )
Pierre-Yves Chibon fd2f9e
        self.session.commit()
Pierre-Yves Chibon fd2f9e
        self.assertEqual(req.id, 1)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(req.title, 'test pull-request')
Pierre-Yves Chibon fd2f9e
        self.assertEqual(repo.open_requests, 1)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        exp = set(['bar@pingou.com'])
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.notify._get_emails_for_obj(req)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, exp)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Comment on the ticket
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.add_pull_request_comment(
Pierre-Yves Chibon fd2f9e
            self.session,
Pierre-Yves Chibon fd2f9e
            request=req,
Pierre-Yves Chibon fd2f9e
            commit=None,
Pierre-Yves Chibon fd2f9e
            tree_id=None,
Pierre-Yves Chibon fd2f9e
            filename=None,
Pierre-Yves Chibon fd2f9e
            row=None,
Pierre-Yves Chibon fd2f9e
            comment='This is a comment',
Pierre-Yves Chibon fd2f9e
            user='foo',
Pierre-Yves Chibon fd2f9e
            requestfolder=None,
Pierre-Yves Chibon fd2f9e
            notify=False)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, 'Comment added')
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        exp = set(['bar@pingou.com', 'foo@bar.com'])
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.notify._get_emails_for_obj(req)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, exp)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        # Create user `bar`
Pierre-Yves Chibon fd2f9e
        item = pagure.lib.model.User(
Pierre-Yves Chibon fd2f9e
            user='bar',
Pierre-Yves Chibon fd2f9e
            fullname='bar name',
Pierre-Yves Chibon fd2f9e
            password='bar',
Pierre-Yves Chibon fd2f9e
            default_email='bar@bar.com',
Pierre-Yves Chibon fd2f9e
        )
Pierre-Yves Chibon fd2f9e
        self.session.add(item)
Pierre-Yves Chibon fd2f9e
        item = pagure.lib.model.UserEmail(
Pierre-Yves Chibon fd2f9e
            user_id=3,
Pierre-Yves Chibon fd2f9e
            email='bar@bar.com')
Pierre-Yves Chibon fd2f9e
        self.session.add(item)
Pierre-Yves Chibon fd2f9e
        self.session.commit()
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon c8242b
        # Watch the pull-request
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.set_watch_obj(self.session, 'bar', req, True)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, 'You are now watching this pull-request')
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
        exp = set(['bar@pingou.com', 'foo@bar.com', 'bar@bar.com'])
Pierre-Yves Chibon fd2f9e
        out = pagure.lib.notify._get_emails_for_obj(req)
Pierre-Yves Chibon fd2f9e
        self.assertEqual(out, exp)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon 33ff8d
    @patch('pagure.lib.notify.smtplib.SMTP')
Pierre-Yves Chibon 33ff8d
    def test_get_emails_for_obj_pr_watching_project(self, mock_smtp):
Pierre-Yves Chibon c8242b
        """ Test the _get_emails_for_obj method from pagure.lib.notify. """
Pierre-Yves Chibon 33ff8d
        mock_smtp.return_value = MagicMock()
Pierre-Yves Chibon 33ff8d
Pierre-Yves Chibon c8242b
        tests.create_projects(self.session)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Create the project ns/test
Pierre-Yves Chibon c8242b
        item = pagure.lib.model.Project(
Pierre-Yves Chibon c8242b
            user_id=1,  # pingou
Pierre-Yves Chibon c8242b
            name='test3',
Pierre-Yves Chibon c8242b
            namespace='ns',
Pierre-Yves Chibon c8242b
            description='test project #1',
Pierre-Yves Chibon c8242b
            hook_token='aaabbbcccdd',
Pierre-Yves Chibon c8242b
        )
Pierre-Yves Chibon c8242b
        item.close_status = ['Invalid', 'Insufficient data', 'Fixed']
Pierre-Yves Chibon c8242b
        self.session.add(item)
Pierre-Yves Chibon c8242b
        self.session.commit()
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Create the PR
Farhaan Bukhsh 481209
        repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon c8242b
        req = pagure.lib.new_pull_request(
Pierre-Yves Chibon c8242b
            session=self.session,
Pierre-Yves Chibon c8242b
            repo_from=repo,
Pierre-Yves Chibon c8242b
            branch_from='master',
Pierre-Yves Chibon c8242b
            repo_to=repo,
Pierre-Yves Chibon c8242b
            branch_to='master',
Pierre-Yves Chibon c8242b
            title='test pull-request',
Pierre-Yves Chibon c8242b
            user='pingou',
Pierre-Yves Chibon c8242b
            requestfolder=None,
Pierre-Yves Chibon c8242b
        )
Pierre-Yves Chibon c8242b
        self.session.commit()
Pierre-Yves Chibon c8242b
        self.assertEqual(req.id, 1)
Pierre-Yves Chibon c8242b
        self.assertEqual(req.title, 'test pull-request')
Pierre-Yves Chibon c8242b
        self.assertEqual(repo.open_requests, 1)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        exp = set(['bar@pingou.com'])
Pierre-Yves Chibon c8242b
        out = pagure.lib.notify._get_emails_for_obj(req)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, exp)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Comment on the ticket
Pierre-Yves Chibon c8242b
        out = pagure.lib.add_pull_request_comment(
Pierre-Yves Chibon c8242b
            self.session,
Pierre-Yves Chibon c8242b
            request=req,
Pierre-Yves Chibon c8242b
            commit=None,
Pierre-Yves Chibon c8242b
            tree_id=None,
Pierre-Yves Chibon c8242b
            filename=None,
Pierre-Yves Chibon c8242b
            row=None,
Pierre-Yves Chibon c8242b
            comment='This is a comment',
Pierre-Yves Chibon c8242b
            user='foo',
Pierre-Yves Chibon c8242b
            requestfolder=None,
Pierre-Yves Chibon c8242b
            notify=False)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, 'Comment added')
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        exp = set(['bar@pingou.com', 'foo@bar.com'])
Pierre-Yves Chibon c8242b
        out = pagure.lib.notify._get_emails_for_obj(req)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, exp)
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Create user `bar`
Pierre-Yves Chibon c8242b
        item = pagure.lib.model.User(
Pierre-Yves Chibon c8242b
            user='bar',
Pierre-Yves Chibon c8242b
            fullname='bar name',
Pierre-Yves Chibon c8242b
            password='bar',
Pierre-Yves Chibon c8242b
            default_email='bar@bar.com',
Pierre-Yves Chibon c8242b
        )
Pierre-Yves Chibon c8242b
        self.session.add(item)
Pierre-Yves Chibon c8242b
        item = pagure.lib.model.UserEmail(
Pierre-Yves Chibon c8242b
            user_id=3,
Pierre-Yves Chibon c8242b
            email='bar@bar.com')
Pierre-Yves Chibon c8242b
        self.session.add(item)
Pierre-Yves Chibon c8242b
        self.session.commit()
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        # Watch the project
Farhaan Bukhsh 481209
        repo = pagure.get_authorized_project(self.session, 'test')
Matt Prahl b49f93
        out = pagure.lib.update_watch_status(self.session, repo, 'bar', '1')
Matt Prahl b49f93
        self.assertEqual(
Pierre-Yves Chibon d7ac66
            out, 'You are now watching issues and PRs on this project')
Pierre-Yves Chibon c8242b
Pierre-Yves Chibon c8242b
        exp = set(['bar@pingou.com', 'foo@bar.com', 'bar@bar.com'])
Pierre-Yves Chibon c8242b
        out = pagure.lib.notify._get_emails_for_obj(req)
Pierre-Yves Chibon c8242b
        self.assertEqual(out, exp)
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon 33ff8d
    @patch('pagure.lib.notify.smtplib.SMTP')
Pierre-Yves Chibon 33ff8d
    def test_send_email(self, mock_smtp):
Pierre-Yves Chibon 4c5244
        """ Test the notify_new_comment method from pagure.lib.notify. """
Pierre-Yves Chibon 33ff8d
        mock_smtp.return_value = MagicMock()
Pierre-Yves Chibon 33ff8d
Pierre-Yves Chibon 4c5244
        email = pagure.lib.notify.send_email(
Pierre-Yves Chibon 4c5244
            'Email content',
Pierre-Yves Chibon 773eb0
            'Email “Subject“',
Pierre-Yves Chibon 4c5244
            'foo@bar.com,zöé@foo.net',
Pierre-Yves Chibon 4c5244
            mail_id='test-pull-request-2edbf96ebe644f4bb31b94605e-1@pagure',
Pierre-Yves Chibon 4c5244
            in_reply_to='test-pull-request-2edbf96ebe644f4bb31b94605e@pagure',
Pierre-Yves Chibon 4c5244
            project_name='namespace/project',
Pierre-Yves Chibon 4c5244
            user_from='Zöé',
Pierre-Yves Chibon 4c5244
        )
Pierre-Yves Chibon 4c5244
        exp = '''Content-Type: text/plain; charset="utf-8"
Pierre-Yves Chibon 4c5244
MIME-Version: 1.0
Pierre-Yves Chibon 4c5244
Content-Transfer-Encoding: base64
Pierre-Yves Chibon 773eb0
Subject: =?utf-8?b?W25hbWVzcGFjZS9wcm9qZWN0XSBFbWFpbCDigJxTdWJqZWN04oCc?=
Pierre-Yves Chibon 4c5244
From: =?utf-8?b?WsO2w6k=?= <pagure@pagure.org></pagure@pagure.org>
Pierre-Yves Chibon 4c5244
mail-id: test-pull-request-2edbf96ebe644f4bb31b94605e-1@pagure
Pierre-Yves Chibon 4c5244
Message-Id: <test-pull-request-2edbf96ebe644f4bb31b94605e-1@pagure></test-pull-request-2edbf96ebe644f4bb31b94605e-1@pagure>
Pierre-Yves Chibon 4c5244
In-Reply-To: <test-pull-request-2edbf96ebe644f4bb31b94605e@pagure></test-pull-request-2edbf96ebe644f4bb31b94605e@pagure>
Pierre-Yves Chibon 8d6e8b
X-Auto-Response-Suppress: All
Pierre-Yves Chibon 4c5244
X-pagure: https://pagure.org/
Pierre-Yves Chibon 4c5244
X-pagure-project: namespace/project
Pierre-Yves Chibon 8d6e8b
List-ID: namespace/project
Pierre-Yves Chibon 8d6e8b
List-Archive: https://pagure.org/namespace/project
Pierre-Yves Chibon 4c5244
To: zöé@foo.net
Pierre-Yves Chibon 4c5244
Reply-To: reply+42f5809bca16d73f59180bdcc76c981e939b5eab5c02930d7d7dd38f45118b89e9ceb877e94e7f22376fbf35aab1d0e8e83dfb074ee82640cc82da12ea8019ca@pagure.org
Pierre-Yves Chibon 4c5244
Mail-Followup-To: reply+42f5809bca16d73f59180bdcc76c981e939b5eab5c02930d7d7dd38f45118b89e9ceb877e94e7f22376fbf35aab1d0e8e83dfb074ee82640cc82da12ea8019ca@pagure.org
Pierre-Yves Chibon 4c5244
Pierre-Yves Chibon 4c5244
RW1haWwgY29udGVudA==
Pierre-Yves Chibon 4c5244
'''
Pierre-Yves Chibon 4c5244
        self.assertEqual(email.as_string(), exp)
Pierre-Yves Chibon 4c5244
Pierre-Yves Chibon 186cd4
        email = pagure.lib.notify.send_email(
Pierre-Yves Chibon 186cd4
            'Email content',
Pierre-Yves Chibon 186cd4
            'Email “Subject“',
Pierre-Yves Chibon 186cd4
            u'foo@bar.com,zöé@foo.net',
Pierre-Yves Chibon 186cd4
            mail_id='test-pull-request-2edbf96ebe644f4bb31b94605e-1@pagure',
Pierre-Yves Chibon 186cd4
            in_reply_to='test-pull-request-2edbf96ebe644f4bb31b94605e@pagure',
Pierre-Yves Chibon 186cd4
            project_name='namespace/project',
Pierre-Yves Chibon 186cd4
            user_from='Zöé',
Pierre-Yves Chibon 186cd4
        )
Pierre-Yves Chibon 186cd4
        self.assertEqual(email.as_string(), exp)
Pierre-Yves Chibon 186cd4
Pierre-Yves Chibon fd2f9e
Pierre-Yves Chibon fd2f9e
if __name__ == '__main__':
Pierre-Yves Chibon 393f31
    unittest.main(verbosity=2)