Пример #1
0
 def test_extra_teams_lookup_duplicate_teams(self):
     team = TeamFactory()
     team_extra_1 = TeamFactory()
     team_extra_2 = TeamFactory()
     settings = TeamNotificationSettings(team=team,
                                         type='mock-type',
                                         url='http://example.com/')
     settings.save()
     settings.extra_teams.add(team_extra_1)
     settings.extra_teams.add(team_extra_2)
     settings.extra_teams.add(team_extra_1)
     assert_equal(TeamNotificationSettings.lookup(team), settings)
     assert_equal(TeamNotificationSettings.lookup(team_extra_1), settings)
     assert_equal(TeamNotificationSettings.lookup(team_extra_2), settings)
Пример #2
0
 def test_send_notification(self):
     team = TeamFactory()
     settings = TeamNotificationSettings(team=team,
                                         type='mock-type',
                                         url='http://example.com/')
     settings.save()
     handler = handlers.NotificationHandlerBase(settings)
     data = {'foo': 'bar'}
     handler.send_notification(data)
     # Note: do_http_post gets replaced with a mock function for the
     # unittests
     assert_equal(
         handlers.do_http_post.delay.call_args,
         mock.call(team.id, settings.url, data, settings.get_headers(),
                   settings.auth_username, settings.auth_password))
Пример #3
0
 def test_extra_teams_lookup_primary_first(self):
     team_1 = TeamFactory()
     team_2 = TeamFactory()
     team_3 = TeamFactory()
     settings_1 = TeamNotificationSettings(team=team_1,
                                           type='mock-type',
                                           url='http://example.com/')
     settings_2 = TeamNotificationSettings(team=team_2,
                                           type='mock-type',
                                           url='http://example.com/')
     settings_1.save()
     settings_2.save()
     settings_1.extra_teams.add(team_2)
     settings_1.extra_teams.add(team_3)
     assert_equal(TeamNotificationSettings.lookup(team_1), settings_1)
     assert_equal(TeamNotificationSettings.lookup(team_2), settings_2)
     assert_equal(TeamNotificationSettings.lookup(team_3), settings_1)