コード例 #1
0
    def test_ignore_regex(self):
        cfg_path = os.path.join(os.path.dirname(__file__), 'assets', 'errbit_ignore.json')
        os.environ['ERRBIT_IGNORE'] = cfg_path
        client = Client()

        self.assertEquals(
            ["^AttributeError\\b", "regex2"],
            client.get_ignore_regex())
コード例 #2
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))
コード例 #3
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))
コード例 #4
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)
コード例 #5
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)
コード例 #6
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)

        self.assertEquals([{'data': '<XMLDATA/>', 'url': 'http://errbit.local/api'}],
                          self.http_client.posted)
コード例 #7
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)
コード例 #8
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)
コード例 #9
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)
コード例 #10
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)
コード例 #11
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']}}
コード例 #12
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())
コード例 #13
0
ファイル: test_client.py プロジェクト: senny/errbit-python
    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())
コード例 #14
0
 def notify_errbit(self, exc_info):
     client = Client()
     client.post(exc_info, request=self.get_request_info())
コード例 #15
0
 def test_ignore_regex_without_cfg(self):
     client = Client()
     self.assertEquals(
         [],
         client.get_ignore_regex())
コード例 #16
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)
コード例 #17
0
ファイル: test_client.py プロジェクト: senny/errbit-python
 def test_set_api_key_with_environment_variables(self):
     os.environ['ERRBIT_API_KEY'] = 'abcd1234'
     client = Client()
     self.assertEquals('abcd1234', client.get_api_key())
コード例 #18
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())
コード例 #19
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())
コード例 #20
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())