Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
 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
Beispiel #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
Beispiel #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
 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