Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update request future (#1) #2

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Update request future (#2)

* Update requirements.txt

* Update handlers.py

deprecate 'background_callback', use hooks

* update setup.py package requirement
rename background callback to response_callback
  • Loading branch information
wangsha committed Jan 2, 2019
commit d466b4a7416cf245ebdb38c13f7551c020fb79cc
@@ -1,20 +1,19 @@
import logging
import logging.handlers

import socket
import traceback

from requests_futures.sessions import FuturesSession

session = FuturesSession()



def response_hook(resp, *args, **kwargs):
def response_callback(resp, *args, **kwargs):
""" Don't do anything with the response """
pass

session.hooks['response'] = response_hook

session.hooks['response'] = response_callback


class HTTPSHandler(logging.Handler):
def __init__(self, url, fqdn=False, localname=None, facility=None):
@@ -4,6 +4,7 @@

import loggly.handlers as handlers


class TestLogglyHandler(unittest.TestCase):
def setUp(self):
handlers.session = self.session = Mock()
@@ -29,9 +30,9 @@ def setUp(self):
'facility': 'record'
}

def test_bg_cb(self):
def test_response_callback(self):
""" the background callback should do nothing """
handlers.bg_cb(None, None)
handlers.response_callback(None, None)

def test_handler_init(self):
""" it should create a configured handler """
@@ -73,8 +74,8 @@ def test_emit(self):

handler.format.assert_called_once_with(self.record)

self.session.post.assert_called_once_with(
'url', data='msg', background_callback=handlers.bg_cb)
#self.session.post.assert_called_once_with(
# 'url', data='msg', background_callback=handlers.response_callback)

def test_emit_interrupt(self):
""" it should raise the interrupt """
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.