コード例 #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
コード例 #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
コード例 #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
コード例 #4
0
ファイル: django_tests.py プロジェクト: apuyou/opbeat_python
 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
コード例 #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
コード例 #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
コード例 #7
0
ファイル: django_tests.py プロジェクト: apuyou/opbeat_python
 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
コード例 #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