|
17 | 17 | )
|
18 | 18 |
|
19 | 19 | import bugsnag.legacy as legacy
|
20 |
| -from tests.utils import IntegrationTest, ScaryException |
| 20 | +from tests.utils import ( |
| 21 | + BrokenDelivery, |
| 22 | + IntegrationTest, |
| 23 | + QueueingDelivery, |
| 24 | + ScaryException, |
| 25 | +) |
21 | 26 |
|
22 | 27 | timestamp_regex = r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(?:[+-]\d{2}:\d{2}|Z)' # noqa: E501
|
23 | 28 |
|
@@ -1688,6 +1693,62 @@ def on_error(event):
|
1688 | 1693 | FeatureFlag('e')
|
1689 | 1694 | ]
|
1690 | 1695 |
|
| 1696 | + def test_in_flight_event_request_tracking_in_notify(self): |
| 1697 | + delivery = QueueingDelivery() |
| 1698 | + configuration = Configuration() |
| 1699 | + configuration.configure(delivery=delivery, api_key='abc') |
| 1700 | + |
| 1701 | + client = Client(configuration) |
| 1702 | + assert not client._request_tracker.has_in_flight_requests() |
| 1703 | + |
| 1704 | + client.notify(Exception('Oh no')) |
| 1705 | + assert client._request_tracker.has_in_flight_requests() |
| 1706 | + |
| 1707 | + delivery.flush_request_queue() |
| 1708 | + assert not client._request_tracker.has_in_flight_requests() |
| 1709 | + |
| 1710 | + def test_in_flight_event_request_tracking_in_notify_failure(self): |
| 1711 | + configuration = Configuration() |
| 1712 | + configuration.configure(delivery=BrokenDelivery(), api_key='abc') |
| 1713 | + |
| 1714 | + client = Client(configuration) |
| 1715 | + assert not client._request_tracker.has_in_flight_requests() |
| 1716 | + |
| 1717 | + client.notify(Exception('Oh no')) |
| 1718 | + assert not client._request_tracker.has_in_flight_requests() |
| 1719 | + |
| 1720 | + def test_in_flight_event_request_tracking_in_notify_exc_info(self): |
| 1721 | + delivery = QueueingDelivery() |
| 1722 | + configuration = Configuration() |
| 1723 | + configuration.configure(delivery=delivery, api_key='abc') |
| 1724 | + |
| 1725 | + client = Client(configuration) |
| 1726 | + assert not client._request_tracker.has_in_flight_requests() |
| 1727 | + |
| 1728 | + try: |
| 1729 | + raise Exception(':)') |
| 1730 | + except Exception: |
| 1731 | + client.notify_exc_info(*sys.exc_info()) |
| 1732 | + |
| 1733 | + assert client._request_tracker.has_in_flight_requests() |
| 1734 | + |
| 1735 | + delivery.flush_request_queue() |
| 1736 | + assert not client._request_tracker.has_in_flight_requests() |
| 1737 | + |
| 1738 | + def test_in_flight_event_request_tracking_in_notify_exc_info_failure(self): |
| 1739 | + configuration = Configuration() |
| 1740 | + configuration.configure(delivery=BrokenDelivery(), api_key='abc') |
| 1741 | + |
| 1742 | + client = Client(configuration) |
| 1743 | + assert not client._request_tracker.has_in_flight_requests() |
| 1744 | + |
| 1745 | + try: |
| 1746 | + raise Exception(':)') |
| 1747 | + except Exception: |
| 1748 | + client.notify_exc_info(*sys.exc_info()) |
| 1749 | + |
| 1750 | + assert not client._request_tracker.has_in_flight_requests() |
| 1751 | + |
1691 | 1752 |
|
1692 | 1753 | @pytest.mark.parametrize("metadata,type", [
|
1693 | 1754 | (1234, 'int'),
|
|
0 commit comments