Exemple #1
0
 def test_client_shutdown_async(self, mock_traces_collect, mock_send):
     client = Client(
         servers=["http://example.com"],
         organization_id="organization_id",
         app_id="app_id",
         secret_token="secret",
         async_mode=True,
     )
     client.send(auth_header="foo", **{"foo": "bar"})
     client.close()
     self.assertEqual(mock_traces_collect.call_count, 1)
     self.assertEqual(mock_send.call_count, 1)
Exemple #2
0
    def test_send_not_enabled(self, time, send_remote):
        time.return_value = 1328055286.51
        with mock.patch.dict("os.environ", {"OPBEAT_DISABLE_SEND": "true"}):
            client = Client(
                servers=["http://example.com"],
                organization_id="organization_id",
                app_id="app_id",
                secret_token="secret",
            )
        client.send(**{"foo": "bar"})

        assert not send_remote.called
Exemple #3
0
 def test_client_shutdown_async(self, mock_traces_collect, mock_send):
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
         async_mode=True,
     )
     client.send(auth_header='foo', **{
         'foo': 'bar',
     })
     client.close()
     self.assertEqual(mock_traces_collect.call_count, 1)
     self.assertEqual(mock_send.call_count, 1)
Exemple #4
0
    def test_send_not_enabled(self, time, send_remote):
        time.return_value = 1328055286.51
        with mock.patch.dict('os.environ', {'OPBEAT_DISABLE_SEND': 'true'}):
            client = Client(
                servers=['http://example.com'],
                organization_id='organization_id',
                app_id='app_id',
                secret_token='secret',
            )
        client.send(**{
            'foo': 'bar',
        })

        assert not send_remote.called
Exemple #5
0
 def test_client_shutdown_async(self, mock_traces_collect, mock_send):
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
         async_mode=True,
     )
     client.send(auth_header='foo', **{
         'foo': 'bar',
     })
     client.close()
     self.assertEqual(mock_traces_collect.call_count, 1)
     self.assertEqual(mock_send.call_count, 1)
Exemple #6
0
    def test_send_not_enabled(self, time, send_remote):
        time.return_value = 1328055286.51
        with mock.patch.dict('os.environ', {'OPBEAT_DISABLE_SEND': 'true'}):
            client = Client(
                servers=['http://example.com'],
                organization_id='organization_id',
                app_id='app_id',
                secret_token='secret',
            )
        client.send(**{
            'foo': 'bar',
        })

        assert not send_remote.called
Exemple #7
0
 def test_send_with_auth_header(self, time, send_remote):
     time.return_value = 1328055286.51
     client = Client(
         servers=["http://example.com"], organization_id="organization_id", app_id="app_id", secret_token="secret"
     )
     client.send(auth_header="foo", **{"foo": "bar"})
     send_remote.assert_called_once_with(
         url="http://example.com",
         data=six.b("x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T"),
         headers={
             "Content-Type": "application/octet-stream",
             "Authorization": "foo",
             "User-Agent": "opbeat-python/%s" % opbeat.VERSION,
             "X-Opbeat-Platform": self.client.get_platform_info(),
         },
     )
 def test_send_with_auth_header(self, time, send_remote):
     time.return_value = 1328055286.51
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
     )
     client.send(auth_header='foo', **{
         'foo': 'bar',
     })
     send_remote.assert_called_once_with(
         url='http://example.com',
         data='x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T',
         headers={
             'Content-Type': 'application/octet-stream',
             'Authorization': 'foo',
             'User-Agent': 'opbeat/%s' % opbeat.VERSION
         },
     )
Exemple #9
0
 def test_send_with_auth_header(self, time, send_remote):
     time.return_value = 1328055286.51
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
     )
     client.send(auth_header='foo', **{
         'foo': 'bar',
     })
     send_remote.assert_called_once_with(
         url='http://example.com',
         data=six.b('x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T'),
         headers={
             'Content-Type': 'application/octet-stream',
             'Authorization': 'foo',
             'User-Agent': 'opbeat-python/%s' % opbeat.VERSION,
             'X-Opbeat-Platform': self.client.get_platform_info(),
         },
     )
Exemple #10
0
 def test_send(self, time, send_remote):
     time.return_value = 1328055286.51
     public = "public"
     access_token = "secret"
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
     )
     client.send(**{
         'foo': 'bar',
     })
     send_remote.assert_called_once_with(
         url='http://example.com',
         data=six.b('x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T'),
         headers={
             'Content-Type': 'application/octet-stream',
             'Authorization': 'Bearer %s' % (access_token),
             'User-Agent': 'opbeat-python/%s' % opbeat.VERSION
         },
     )
Exemple #11
0
 def test_send(self, time, send_remote):
     time.return_value = 1328055286.51
     public = "public"
     access_token = "secret"
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
     )
     client.send(**{
         'foo': 'bar',
     })
     send_remote.assert_called_once_with(
         url='http://example.com',
         data=six.b('x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T'),
         headers={
             'Content-Type': 'application/octet-stream',
             'Authorization': 'Bearer %s' % (access_token),
             'User-Agent': 'opbeat-python/%s' % opbeat.VERSION
         },
     )
Exemple #12
0
 def test_send_with_auth_header(self, time, send_remote):
     time.return_value = 1328055286.51
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
     )
     client.send(auth_header='foo', **{
         'foo': 'bar',
     })
     send_remote.assert_called_once_with(
         url='http://example.com',
         data=six.b('x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T'),
         headers={
             'Content-Type': 'application/json',
             'Content-Encoding': 'deflate',
             'Authorization': 'foo',
             'User-Agent': 'opbeat-python/%s' % opbeat.VERSION,
             'X-Opbeat-Platform': self.client.get_platform_info(),
         },
     )