コード例 #1
0
    def test_client_logs_invalid_config_file(self):
        os.environ['ERRBIT_IGNORE'] = __file__
        os.environ['ERRBIT_API_KEY'] = 'abcd1234'
        os.environ['ERRBIT_URL'] = 'http://errbit.local/api'

        client = Client()
        client.post(EXC_INFO, request={'url': 'http://foo/bar'})
        while threading.active_count() > 1:
            pass

        self.assertEquals(2, len(self.http_client.posted))
コード例 #2
0
    def test_client_filters_test_exception(self):
        cfg_path = os.path.join(os.path.dirname(__file__), 'assets',
                                'errbit_ignore.json')
        os.environ['ERRBIT_IGNORE'] = cfg_path
        os.environ['ERRBIT_API_KEY'] = 'abcd1234'
        os.environ['ERRBIT_URL'] = 'http://errbit.local/api'

        client = Client()
        client.post(EXC_INFO, request={'url': 'http://foo/bar'})
        while threading.active_count() > 1:
            pass

        self.assertEquals([], self.http_client.posted)
コード例 #3
0
ファイル: test_client.py プロジェクト: senny/errbit-python
    def test_posting_exception(self):
        os.environ['ERRBIT_API_KEY'] = 'abcd1234'
        os.environ['ERRBIT_URL'] = 'http://errbit.local/api'
        request_data = {'url': 'http://foo/bar'}
        env_data = {'project-root': os.getcwd()}
        client = Client()

        xmlgenerator = self.mocker.replace('errbit.xmlgenerator.generate_xml')
        self.expect(
            xmlgenerator('abcd1234',
                         client.get_notifier(),
                         EXC_INFO,
                         request=request_data,
                         environment=env_data)).result('<XMLDATA/>')

        req_class = self.mocker.replace('errbit.request.ThreadedRequest')
        req = self.mocker.mock()
        self.expect(req_class('http://errbit.local/api',
                              '<XMLDATA/>')).result(req)
        self.expect(req.start())

        self.mocker.replay()
        client.post(EXC_INFO, request=request_data)
コード例 #4
0
    def test_posting_exception(self):
        os.environ['ERRBIT_API_KEY'] = 'abcd1234'
        os.environ['ERRBIT_URL'] = 'http://errbit.local/api'
        request_data = {'url': 'http://foo/bar'}
        env_data = {'project-root': os.getcwd()}
        client = Client()

        xmlgenerator = self.mocker.replace('errbit.xmlgenerator.generate_xml')
        self.expect(
            xmlgenerator('abcd1234',
                         client.get_notifier(),
                         EXC_INFO,
                         request=request_data,
                         environment=env_data)).result('<XMLDATA/>')

        self.mocker.replay()
        client.post(EXC_INFO, request=request_data)
        while threading.active_count() > 1:
            pass

        self.assertEquals([{
            'data': '<XMLDATA/>',
            'url': 'http://errbit.local/api'
        }], self.http_client.posted)
コード例 #5
0
 def notify_errbit(self, exc_info):
     client = Client()
     request_info = self.get_request_info()
     request_info = cleanup_request_info(request_info)
     client.post(exc_info, request=request_info)
コード例 #6
0
os.environ['ERRBIT_HTTP_CLIENT'] = http_client or 'requests'
print ''


class ErrbitPythonClientTesting(Exception):
    pass


from errbit.client import Client

client = Client()
try:
    raise ErrbitPythonClientTesting('We have an exception!')
except:
    exc_info = sys.exc_info()

    request = {
        'url': 'http://my.app/app/folders/create',
        'component': 'folders',
        'action': 'create',
        'params': {
            'title': 'My Folder'},
        'session': {
            'cookie': 'session_id=123345'},
        'cgi-data': {
            'ERRBIT_HTTP_CLIENT': os.environ['ERRBIT_HTTP_CLIENT']}}

    client.post(exc_info, request=request)

print ''
コード例 #7
0
 def notify_errbit(self, exc_info):
     client = Client()
     client.post(exc_info, request=self.get_request_info())