def test_make_email_tasks__update(self, mock_f_e_b):
     """We send email to component owners and subscribers for edits."""
     mock_f_e_b.return_value = 'mock body html'
     actual_tasks = notifier.make_email_tasks(self.feature_1, True,
                                              self.changes)
     self.assertEqual(2, len(actual_tasks))
     owner_task, watcher_task = actual_tasks
     self.assertEqual('updated feature: feature one', owner_task['subject'])
     self.assertIn('mock body html', owner_task['html'])
     self.assertEqual('*****@*****.**', owner_task['to'])
     self.assertEqual('updated feature: feature one',
                      watcher_task['subject'])
     self.assertIn('mock body html', watcher_task['html'])
     self.assertEqual('*****@*****.**', watcher_task['to'])
     mock_f_e_b.assert_called_once_with(True, self.feature_1, self.changes)
 def test_make_email_tasks__starrer_unsubscribed(self, mock_f_e_b):
     """We don't email users who starred the feature but opted out."""
     mock_f_e_b.return_value = 'mock body html'
     starrer_2_pref = models.UserPref(email='*****@*****.**',
                                      notify_as_starrer=False)
     starrer_2_pref.put()
     notifier.FeatureStar.set_star('*****@*****.**',
                                   self.feature_2.key().id())
     actual_tasks = notifier.make_email_tasks(self.feature_2, True,
                                              self.changes)
     self.assertEqual(2, len(actual_tasks))
     # Note: There is no starrer_task.
     owner_task, watcher_task = actual_tasks
     self.assertEqual('*****@*****.**', owner_task['to'])
     self.assertEqual('*****@*****.**', watcher_task['to'])
     mock_f_e_b.assert_called_once_with(True, self.feature_2, self.changes)
 def test_make_email_tasks__starrer(self, mock_f_e_b):
     """We send email to users who starred the feature."""
     mock_f_e_b.return_value = 'mock body html'
     notifier.FeatureStar.set_star('*****@*****.**',
                                   self.feature_1.key().id())
     actual_tasks = notifier.make_email_tasks(self.feature_1, True,
                                              self.changes)
     self.assertEqual(3, len(actual_tasks))
     owner_task, starrer_task, watcher_task = actual_tasks
     self.assertEqual('updated feature: feature one', owner_task['subject'])
     self.assertIn('mock body html', owner_task['html'])
     self.assertEqual('*****@*****.**', owner_task['to'])
     self.assertEqual('*****@*****.**', starrer_task['to'])
     self.assertEqual('updated feature: feature one',
                      watcher_task['subject'])
     self.assertIn('mock body html', watcher_task['html'])
     self.assertEqual('*****@*****.**', watcher_task['to'])
     mock_f_e_b.assert_called_once_with(True, self.feature_1, self.changes)