# Path: bugsnag/breadcrumbs.py
# class BreadcrumbType(Enum):
#     NAVIGATION = 'navigation'
#     REQUEST = 'request'
#     PROCESS = 'process'
#     LOG = 'log'
#     USER = 'user'
#     STATE = 'state'
#     ERROR = 'error'
#     MANUAL = 'manual'
# 
# Path: tests/utils.py
# class IntegrationTest(unittest.TestCase):
# 
#     @classmethod
#     def setUpClass(cls):
#         cls.server = FakeBugsnagServer()
# 
#     def setUp(self):
#         self.server.received = []
# 
#     def tearDown(self):
#         bugsnag.legacy.default_client.uninstall_sys_hook()
#         client = bugsnag.Client()
#         client.configuration.api_key = 'some key'
#         bugsnag.legacy.default_client = client
#         bugsnag.legacy.configuration = client.configuration
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.server.shutdown()
# 
#     def assertSentReportCount(self, count):
#         self.assertEqual(len(self.server.received), count)
# 
#     def assertExceptionName(self, received_index, event_index, name):
#         json_body = self.server.received[received_index]['json_body']
#         event = json_body['events'][event_index]
#         exception = event['exceptions'][0]
#         self.assertEqual(exception['errorClass'], name)
# 
#     @property
#     def sent_report_count(self) -> int:
#         return len(self.server.received)
# 
# Path: tests/fixtures/tornado/server.py
# class CrashHandler(BugsnagRequestHandler):
# class CrashWithCallbackHandler(BugsnagRequestHandler):
# class NotifyHandler(BugsnagRequestHandler):
#     def get(self):
#     def post(self):
#     def get(self):
# def callback(notification):
#     def get(self):
#     def post(self):
# def make_app():


import bugsnag
import json
from bugsnag.breadcrumbs import BreadcrumbType
from tests.utils import IntegrationTest
from tornado.testing import AsyncHTTPTestCase
from tests.fixtures.tornado import server

        breadcrumbs = event['breadcrumbs']

        assert len(breadcrumbs) == 1
        assert breadcrumbs[0]['name'] == 'http request'
        assert breadcrumbs[0]['metaData'] == {'to': '/notify'}
        assert breadcrumbs[0]['type'] == BreadcrumbType.NAVIGATION.value

    def test_notify_get(self):
        response = self.fetch('/notify?test=get', method="GET")
        self.assertEqual(response.code, 200)
        self.assertEqual(len(self.server.received), 1)

        payload = self.server.received[0]['json_body']
        event = payload['events'][0]
        p = self.get_http_port()
        expectedUrl = 'http://127.0.0.1:{}/notify?test=get'.format(p)
        self.assertEqual(event['metaData']['request'], {
            'method': 'GET',
            'url': expectedUrl,
            'path': '/notify',
            'POST': {},
            'GET': {'test': ['get']}
        })

        breadcrumbs = event['breadcrumbs']

        assert len(breadcrumbs) == 1
        assert breadcrumbs[0]['name'] == 'http request'
        assert breadcrumbs[0]['metaData'] == {'to': '/notify'}

# Path: bugsnag/breadcrumbs.py
# class BreadcrumbType(Enum):
#     NAVIGATION = 'navigation'
#     REQUEST = 'request'
#     PROCESS = 'process'
#     LOG = 'log'
#     USER = 'user'
#     STATE = 'state'
#     ERROR = 'error'
#     MANUAL = 'manual'
# 
# Path: tests/utils.py
# class IntegrationTest(unittest.TestCase):
# 
#     @classmethod
#     def setUpClass(cls):
#         cls.server = FakeBugsnagServer()
# 
#     def setUp(self):
#         self.server.received = []
# 
#     def tearDown(self):
#         bugsnag.legacy.default_client.uninstall_sys_hook()
#         client = bugsnag.Client()
#         client.configuration.api_key = 'some key'
#         bugsnag.legacy.default_client = client
#         bugsnag.legacy.configuration = client.configuration
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.server.shutdown()
# 
#     def assertSentReportCount(self, count):
#         self.assertEqual(len(self.server.received), count)
# 
#     def assertExceptionName(self, received_index, event_index, name):
#         json_body = self.server.received[received_index]['json_body']
#         event = json_body['events'][event_index]
#         exception = event['exceptions'][0]
#         self.assertEqual(exception['errorClass'], name)
# 
#     @property
#     def sent_report_count(self) -> int:
#         return len(self.server.received)
# 
# Path: tests/fixtures/tornado/server.py
# class CrashHandler(BugsnagRequestHandler):
# class CrashWithCallbackHandler(BugsnagRequestHandler):
# class NotifyHandler(BugsnagRequestHandler):
#     def get(self):
#     def post(self):
#     def get(self):
# def callback(notification):
#     def get(self):
#     def post(self):
# def make_app():


# Path: tests/integrations/test_tornado.py
import bugsnag
import json
from bugsnag.breadcrumbs import BreadcrumbType
from tests.utils import IntegrationTest
from tornado.testing import AsyncHTTPTestCase
from tests.fixtures.tornado import server


        breadcrumbs = event['breadcrumbs']

        assert len(breadcrumbs) == 1
        assert breadcrumbs[0]['name'] == 'http request'
        assert breadcrumbs[0]['metaData'] == {'to': '/notify'}
        assert breadcrumbs[0]['type'] == BreadcrumbType.NAVIGATION.value

    def test_notify_get(self):
        response = self.fetch('/notify?test=get', method="GET")
        self.assertEqual(response.code, 200)
        self.assertEqual(len(self.server.received), 1)

        payload = self.server.received[0]['json_body']
        event = payload['events'][0]
        p = self.get_http_port()
        expectedUrl = 'http://127.0.0.1:{}/notify?test=get'.format(p)
        self.assertEqual(event['metaData']['request'], {
            'method': 'GET',
            'url': expectedUrl,
            'path': '/notify',
            'POST': {},
            'GET': {'test': ['get']}
        })

        breadcrumbs = event['breadcrumbs']

        assert len(breadcrumbs) == 1
        assert breadcrumbs[0]['name'] == 'http request'
        assert breadcrumbs[0]['metaData'] == {'to': '/notify'}

        assert breadcrumbs[0]['type'] == BreadcrumbType.NAVIGATION.value