Exemplo n.º 1
0
 def test_middleware_not_set(self):
     stdout = six.StringIO()
     command = DjangoCommand()
     with self.settings(MIDDLEWARE_CLASSES=()):
         command.execute('check', stdout=stdout)
     output = stdout.getvalue()
     assert 'Opbeat APM middleware not set!' in output
Exemplo n.º 2
0
 def test_subcommand_not_known(self, argv_mock):
     stdout = six.StringIO()
     command = DjangoCommand()
     argv_mock.return_value = ['manage.py', 'opbeat']
     command.execute('foo', stdout=stdout)
     output = stdout.getvalue()
     assert 'No such command "foo"' in output
Exemplo n.º 3
0
 def test_subcommand_not_set(self, argv_mock):
     stdout = six.StringIO()
     command = DjangoCommand()
     argv_mock.return_value = ['manage.py', 'opbeat']
     command.execute(stdout=stdout)
     output = stdout.getvalue()
     assert 'No command specified' in output
Exemplo n.º 4
0
 def test_middleware_not_first(self):
     stdout = six.StringIO()
     command = DjangoCommand()
     with self.settings(MIDDLEWARE_CLASSES=(
             'foo',
             'opbeat.contrib.django.middleware.OpbeatAPMMiddleware')):
         command.execute('check', stdout=stdout)
     output = stdout.getvalue()
     assert 'not at the first position' in output
Exemplo n.º 5
0
 def test_middleware_not_first(self):
     stdout = six.StringIO()
     command = DjangoCommand()
     with self.settings(MIDDLEWARE_CLASSES=(
         'foo',
         'opbeat.contrib.django.middleware.OpbeatAPMMiddleware'
     )):
         command.execute('check', stdout=stdout)
     output = stdout.getvalue()
     assert 'not at the first position' in output
Exemplo n.º 6
0
 def test_settings_missing(self):
     stdout = six.StringIO()
     command = DjangoCommand()
     with self.settings(OPBEAT={}):
         command.execute('check', stdout=stdout)
     output = stdout.getvalue()
     assert 'Configuration errors detected' in output
     assert 'ORGANIZATION_ID not set' in output
     assert 'APP_ID not set' in output
     assert 'SECRET_TOKEN not set' in output
Exemplo n.º 7
0
 def test_test_exception(self, urlopen_mock):
     stdout = six.StringIO()
     command = DjangoCommand()
     resp = six.moves.urllib.response.addinfo(
         mock.Mock(), headers={'Location': 'http://example.com'})
     urlopen_mock.return_value = resp
     with self.settings(MIDDLEWARE_CLASSES=(
             'foo',
             'opbeat.contrib.django.middleware.OpbeatAPMMiddleware')):
         command.execute('test', stdout=stdout, stderr=stdout)
     output = stdout.getvalue()
     assert 'http://example.com' in output
Exemplo n.º 8
0
 def test_test_exception(self, urlopen_mock):
     stdout = six.StringIO()
     command = DjangoCommand()
     resp = six.moves.urllib.response.addinfo(
         mock.Mock(),
         headers={'Location': 'http://example.com'}
     )
     urlopen_mock.return_value = resp
     with self.settings(MIDDLEWARE_CLASSES=(
             'foo',
             'opbeat.contrib.django.middleware.OpbeatAPMMiddleware'
     )):
         command.execute('test', stdout=stdout, stderr=stdout)
     output = stdout.getvalue()
     assert 'http://example.com' in output