def test_get_headers(self): settings = TeamNotificationSettings( header1='Foo: bar', header2=' Foo2: bar2', # extra space should be trimmed ) assert_equal(settings.get_headers(), { 'Foo': 'bar', 'Foo2': 'bar2', })
def test_send_notification(self): team = TeamFactory() settings = TeamNotificationSettings(team=team, type='mock-type', url='http://example.com/') 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))