Exemple #1
0
 def test_smoke_admining_team(self):
     # Smoke test, primarily for DB permissions needed by queries to work
     # with admining users and teams
     # Check the oopses in /var/tmp/lperr.test if the assertions fail.
     self.useFixture(FeatureFixture({
             'jobs.celery.enabled_classes': 'MembershipNotificationJob'
     }))
     team = self.factory.makeTeam(name='a-team')
     with person_logged_in(team.teamowner):
         # This implicitly creates a job, but it is not the job under test.
         admining_team = self.factory.makeTeam()
         team.addMember(
             admining_team, team.teamowner, force_team_add=True)
         membership = getUtility(ITeamMembershipSet).getByPersonAndTeam(
             admining_team, team)
         membership.setStatus(
             TeamMembershipStatus.ADMIN, team.teamowner)
     person = self.factory.makePerson(name='murdock')
     with block_on_job(self):
         transaction.commit()
     pop_remote_notifications()
     job = getUtility(IMembershipNotificationJobSource).create(
         person, team, team.teamowner,
         TeamMembershipStatus.APPROVED, TeamMembershipStatus.ADMIN)
     with block_on_job(self):
         transaction.commit()
     self.assertEqual(JobStatus.COMPLETED, job.status)
     (notification,) = pop_remote_notifications()
     self.assertIn('murdock made admin by', notification['Subject'])
 def test_uncommit_branch(self):
     """RevisionMailJob for removed revisions runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     uncommit(tree.branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def test_uncommit_branch(self):
     """RevisionMailJob for removed revisions runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     uncommit(tree.branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def test_revisions_added(self):
     """RevisionsAddedJob for added revisions runs via Celery."""
     # Enable RevisionMailJob to let celery activate a new connection
     # before trying to flush sent emails calling pop_remote_notifications.
     db_branch, tree = self.prepare('RevisionMailJob RevisionsAddedJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     tree.commit('message2')
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def test_revisions_added(self):
     """RevisionsAddedJob for added revisions runs via Celery."""
     # Enable RevisionMailJob to let celery activate a new connection
     # before trying to flush sent emails calling pop_remote_notifications.
     db_branch, tree = self.prepare('RevisionMailJob RevisionsAddedJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     tree.commit('message2')
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
Exemple #6
0
 def test_ReviewRequestedEmailJob(self):
     """ReviewRequestedEmailJob runs under Celery."""
     request = self.factory.makeCodeReviewVoteReference()
     self.useFixture(FeatureFixture(
         {'jobs.celery.enabled_classes': 'ReviewRequestedEmailJob'}))
     with block_on_job():
         ReviewRequestedEmailJob.create(request)
         transaction.commit()
     self.assertEqual(1, len(pop_remote_notifications()))
Exemple #7
0
 def test_CodeReviewCommentEmailJob(self):
     """CodeReviewCommentEmailJob runs under Celery."""
     comment = self.factory.makeCodeReviewComment()
     self.useFixture(FeatureFixture(
         {'jobs.celery.enabled_classes': 'CodeReviewCommentEmailJob'}))
     with block_on_job():
         CodeReviewCommentEmailJob.create(comment)
         transaction.commit()
     self.assertEqual(2, len(pop_remote_notifications()))
Exemple #8
0
 def test_MergeProposalUpdatedEmailJob(self):
     """MergeProposalUpdatedEmailJob runs under Celery."""
     bmp = self.factory.makeBranchMergeProposal()
     self.useFixture(FeatureFixture(
         {'jobs.celery.enabled_classes': 'MergeProposalUpdatedEmailJob'}))
     with block_on_job():
         MergeProposalUpdatedEmailJob.create(
             bmp, 'change', bmp.registrant)
         transaction.commit()
     self.assertEqual(2, len(pop_remote_notifications()))
 def test_run(self):
     # The email is sent to all the recipients.
     # Create the question before turning on the feature flag to avoid
     # running two jobs via Celery.
     question = self.factory.makeQuestion()
     self.useFixture(FeatureFixture({
         'jobs.celery.enabled_classes': 'QuestionEmailJob',
     }))
     body = self.factory.getUniqueString('body')
     make_question_job(
         self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER,
         question=question, body=body)
     with block_on_job(self):
         transaction.commit()
     transaction.commit()
     mail = pop_remote_notifications()
     self.assertEqual(2, len(mail))
     for message in mail:
         self.assertIn(body, message.get_payload())
Exemple #10
0
 def test_run(self):
     # The email is sent to all the recipients.
     # Create the question before turning on the feature flag to avoid
     # running two jobs via Celery.
     question = self.factory.makeQuestion()
     self.useFixture(
         FeatureFixture({
             'jobs.celery.enabled_classes': 'QuestionEmailJob',
         }))
     body = self.factory.getUniqueString('body')
     make_question_job(self.factory,
                       QuestionRecipientSet.ASKER_SUBSCRIBER,
                       question=question,
                       body=body)
     with block_on_job(self):
         transaction.commit()
     transaction.commit()
     mail = pop_remote_notifications()
     self.assertEqual(2, len(mail))
     for message in mail:
         self.assertIn(body, message.get_payload())
Exemple #11
0
 def test_empty_branch(self):
     """RevisionMailJob for empty branches runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     with block_on_job():
         BzrSync(db_branch).syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def test_empty_branch(self):
     """RevisionMailJob for empty branches runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     with block_on_job():
         BzrSync(db_branch).syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))