def setUp(self):
   self.feature_1 = models.Feature(
       name='feature one', summary='sum', category=1, visibility=1,
       standardization=1, web_dev_views=1, impl_status_chrome=1,
       created_by=users.User('*****@*****.**'),
       updated_by=users.User('*****@*****.**'))
   self.feature_1.put()
   self.component_1 = models.BlinkComponent(name='Blink')
   self.component_1.put()
   self.owner_1 = models.FeatureOwner(
       name='owner_1', email='*****@*****.**',
       primary_blink_components=[self.component_1.key()])
   self.owner_1.put()
   self.watcher_1 = models.FeatureOwner(
       name='watcher_1', email='*****@*****.**',
       watching_all_features=True)
   self.watcher_1.put()
Ejemplo n.º 2
0
 def setUp(self):
     self.feature_1 = models.Feature(
         name='feature one',
         summary='sum',
         category=1,
         visibility=1,
         standardization=1,
         web_dev_views=1,
         impl_status_chrome=1,
         created_by=users.User('*****@*****.**'),
         updated_by=users.User('*****@*****.**'),
         blink_components=['Blink'])
     self.feature_1.put()
     self.component_1 = models.BlinkComponent(name='Blink')
     self.component_1.put()
     self.owner_1 = models.FeatureOwner(
         name='owner_1',
         email='*****@*****.**',
         primary_blink_components=[self.component_1.key()])
     self.owner_1.put()
     self.watcher_1 = models.FeatureOwner(name='watcher_1',
                                          email='*****@*****.**',
                                          watching_all_features=True)
     self.watcher_1.put()
     self.changes = [
         dict(prop_name='test_prop',
              new_val='test new value',
              old_val='test old value')
     ]
     self.feature_2 = models.Feature(
         name='feature two',
         summary='sum',
         category=1,
         visibility=1,
         standardization=1,
         web_dev_views=1,
         impl_status_chrome=1,
         created_by=users.User('*****@*****.**'),
         updated_by=users.User('*****@*****.**'),
         blink_components=['Blink'])
     self.feature_2.put()
 def test_compose_email_for_one_component__new(self, mock_f_e_b):
   """We send email to component owners and subscribers for new features."""
   mock_f_e_b.return_value = 'mock body html'
   message = notifier.compose_email_for_one_component(
       self.feature_1, False, [],
       [models.FeatureOwner(name='watcher_2', email='*****@*****.**')],
       self.component_1)
   self.assertEqual('new feature: feature one', message.subject)
   self.assertEqual('mock body html', message.html)
   self.assertEqual(['*****@*****.**'], message.to)
   self.assertEqual(['*****@*****.**'], message.cc)
   mock_f_e_b.assert_called_once_with(
       False, self.feature_1, self.component_1, [])
 def test_compose_email_for_one_component__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'
   changes = [dict(prop_name='test_prop', new_val='test new value',
                   old_val='test old value')]
   message = notifier.compose_email_for_one_component(
       self.feature_1, True, changes,
       [models.FeatureOwner(name='watcher_2', email='*****@*****.**')],
       self.component_1)
   self.assertEqual('updated feature: feature one', message.subject)
   self.assertEqual('mock body html', message.html)
   self.assertEqual(['*****@*****.**'], message.to)
   self.assertEqual(['*****@*****.**'], message.cc)
   mock_f_e_b.assert_called_once_with(
       True, self.feature_1, self.component_1, changes)
Ejemplo n.º 5
0
  def __populate_subscribers(self):
    """Seeds the database with the team in devrel_team.yaml and adds the team
      member to the specified blink components in that file. Should only be ran
      if the FeatureOwner database entries have been cleared"""
    f = file('%s/data/devrel_team.yaml' % settings.ROOT_DIR, 'r')
    for profile in yaml.load_all(f):
      blink_components = profile.get('blink_components', [])
      blink_components = [models.BlinkComponent.get_by_name(name).key() for name in blink_components]
      blink_components = filter(None, blink_components) # Filter out None values

      user = models.FeatureOwner(
        name=unicode(profile['name']),
        email=unicode(profile['email']),
        twitter=profile.get('twitter', None),
        blink_components=blink_components
      )
      user.put()
    f.close()