Example #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))
Example #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)
Example #3
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/>')

        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)
Example #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)
Example #5
0
    def test_configure_errbit_url_with_environment_variable(self):
        os.environ['ERRBIT_URL'] = 'http://errbit.local/api'

        client = Client()
        self.assertEquals('http://errbit.local/api', client.get_errbit_url())
Example #6
0
 def test_set_api_key_with_environment_variables(self):
     os.environ['ERRBIT_API_KEY'] = 'abcd1234'
     client = Client()
     self.assertEquals('abcd1234', client.get_api_key())
Example #7
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)
Example #8
0
print ' -', '\n - '.join(HTTP_CLIENTS.keys())

while http_client and http_client not in HTTP_CLIENTS.keys():
    http_client = raw_input('Client (Default: "requests"): ').strip()

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']}}
Example #9
0
 def notify_errbit(self, exc_info):
     client = Client()
     client.post(exc_info, request=self.get_request_info())