def test_headers(self):
     # The headers property matches the headers passed to create().
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(
         question, user, QuestionRecipientSet.SUBSCRIBER,
         subject, body, headers)
     self.assertEqual(headers, job.headers)
Beispiel #2
0
 def test_headers(self):
     # The headers property matches the headers passed to create().
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(question, user,
                                   QuestionRecipientSet.SUBSCRIBER, subject,
                                   body, headers)
     self.assertEqual(headers, job.headers)
Beispiel #3
0
 def test_getOopsVars(self):
     # The getOopsVars() method adds the question and user to the vars.
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(question, user,
                                   QuestionRecipientSet.SUBSCRIBER, subject,
                                   body, headers)
     oops_vars = job.getOopsVars()
     self.assertTrue(('question', question.id) in oops_vars)
     self.assertTrue(('user', user.name) in oops_vars)
Beispiel #4
0
 def test_from_address(self):
     # The from_address is the question with the user displayname.
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(question, user,
                                   QuestionRecipientSet.SUBSCRIBER, subject,
                                   body, headers)
     address = format_address(
         user.displayname, "*****@*****.**" % question.id)
     self.assertEqual(address, job.from_address)
 def test_getOopsVars(self):
     # The getOopsVars() method adds the question and user to the vars.
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(
         question, user, QuestionRecipientSet.SUBSCRIBER,
         subject, body, headers)
     oops_vars = job.getOopsVars()
     self.assertTrue(('question', question.id) in oops_vars)
     self.assertTrue(('user', user.name) in oops_vars)
 def test_from_address(self):
     # The from_address is the question with the user displayname.
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(
         question, user, QuestionRecipientSet.SUBSCRIBER,
         subject, body, headers)
     address = format_address(
         user.displayname,
         "*****@*****.**" % question.id)
     self.assertEqual(address, job.from_address)
def make_question_job(factory, recipient_set=QuestionRecipientSet.SUBSCRIBER,
                      body=None, question=None, user=None):
    if question is None:
        question = factory.makeQuestion()
    default_user, subject, default_body, headers = (
        make_user_subject_body_headers(factory))
    if body is None:
        body = default_body
    if user is None:
        user = default_user
    contact = factory.makePerson()
    with person_logged_in(contact):
        lang_set = getUtility(ILanguageSet)
        contact.addLanguage(lang_set['en'])
        question.target.addAnswerContact(contact, contact)
    return QuestionEmailJob.create(
        question, user, recipient_set,
        subject, body, headers)
Beispiel #8
0
def make_question_job(factory,
                      recipient_set=QuestionRecipientSet.SUBSCRIBER,
                      body=None,
                      question=None,
                      user=None):
    if question is None:
        question = factory.makeQuestion()
    default_user, subject, default_body, headers = (
        make_user_subject_body_headers(factory))
    if body is None:
        body = default_body
    if user is None:
        user = default_user
    contact = factory.makePerson()
    with person_logged_in(contact):
        lang_set = getUtility(ILanguageSet)
        contact.addLanguage(lang_set['en'])
        question.target.addAnswerContact(contact, contact)
    return QuestionEmailJob.create(question, user, recipient_set, subject,
                                   body, headers)
Beispiel #9
0
 def test_create(self):
     # The create class method converts the extra job arguments
     # to metadata.
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(question, user,
                                   QuestionRecipientSet.SUBSCRIBER, subject,
                                   body, headers)
     self.assertEqual(QuestionJobType.EMAIL, job.job_type)
     self.assertEqual(question, job.question)
     self.assertContentEqual(
         ['body', 'headers', 'recipient_set', 'subject', 'user'],
         job.metadata.keys())
     self.assertEqual(user.id, job.metadata['user'])
     self.assertEqual(QuestionRecipientSet.SUBSCRIBER.name,
                      job.metadata['recipient_set'])
     self.assertEqual(subject, job.metadata['subject'])
     self.assertEqual(body, job.metadata['body'])
     self.assertEqual(headers['X-Launchpad-Question'],
                      job.metadata['headers']['X-Launchpad-Question'])
     self.assertProvides(job, IQuestionEmailJob)
 def test_create(self):
     # The create class method converts the extra job arguments
     # to metadata.
     question = self.factory.makeQuestion()
     user, subject, body, headers = make_user_subject_body_headers(
         self.factory)
     job = QuestionEmailJob.create(
         question, user, QuestionRecipientSet.SUBSCRIBER,
         subject, body, headers)
     self.assertEqual(QuestionJobType.EMAIL, job.job_type)
     self.assertEqual(question, job.question)
     self.assertContentEqual(
         ['body', 'headers', 'recipient_set', 'subject', 'user'],
         job.metadata.keys())
     self.assertEqual(user.id, job.metadata['user'])
     self.assertEqual(
         QuestionRecipientSet.SUBSCRIBER.name,
         job.metadata['recipient_set'])
     self.assertEqual(subject, job.metadata['subject'])
     self.assertEqual(body, job.metadata['body'])
     self.assertEqual(
         headers['X-Launchpad-Question'],
         job.metadata['headers']['X-Launchpad-Question'])
     self.assertProvides(job, IQuestionEmailJob)