-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathtest_sessionmiddleware.py
44 lines (32 loc) · 1.42 KB
/
test_sessionmiddleware.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import unittest
from bugsnag.sessiontracker import SessionTracker, SessionMiddleware
from bugsnag.configuration import Configuration
from bugsnag.notification import Notification
class TestSessionMiddleware(unittest.TestCase):
def setUp(self):
self.config = Configuration()
self.config.configure(api_key='fff', auto_capture_sessions=False)
self.sessiontracker = SessionTracker(self.config)
self.sessiontracker.auto_sessions = True # Stub session delivery queue
def tearDown(self):
pass
def test_increment_counts(self):
"""
Every event should keep a list of prior events which occurred in the
session
"""
def next_callable(event):
pass
middleware = SessionMiddleware(next_callable)
self.sessiontracker.start_session()
event = Notification(Exception('shucks'), self.config, None)
middleware(event)
assert event.session['events']['unhandled'] == 0
assert event.session['events']['handled'] == 1
event2 = Notification(Exception('oh no'), self.config, None)
middleware(event2)
assert event2.session['events']['unhandled'] == 0
assert event2.session['events']['handled'] == 2
# Session counts should not change for events already handled
assert event.session['events']['unhandled'] == 0
assert event.session['events']['handled'] == 1