Commit f9f4f1c5 by Brian Wilson

Add additional tests for tracking of sessions.

parent 119d7768
......@@ -124,6 +124,13 @@ class TrackMiddlewareTestCase(TestCase):
'session': expected_session_key,
})
@override_settings(SECRET_KEY='85920908f28904ed733fe576320db18cabd7b6cd')
def test_session_key_encryption(self):
session_key = '665924b49a93e22b46ee9365abf28c2a'
expected_session_key = '3b81f559d14130180065d635a4f35dd2'
encrypted_session_key = self.track_middleware.encrypt_session_key(session_key)
self.assertEquals(encrypted_session_key, expected_session_key)
def test_request_headers(self):
ip_address = '10.0.0.0'
user_agent = 'UnitTest/1.0'
......
......@@ -7,6 +7,8 @@ from freezegun import freeze_time
from django.test import TestCase
from django.test.client import RequestFactory
from eventtracking import tracker
from datetime import datetime
expected_time = datetime(2013, 10, 3, 8, 24, 55)
......@@ -34,11 +36,12 @@ class TestTrackViews(TestCase):
'event_type': sentinel.event_type,
'event': {}
})
with tracker.get_tracker().context('edx.request', {'session': sentinel.session}):
views.user_track(request)
expected_event = {
'username': 'anonymous',
'session': '',
'session': sentinel.session,
'ip': '127.0.0.1',
'event_source': 'browser',
'event_type': str(sentinel.event_type),
......@@ -50,6 +53,7 @@ class TestTrackViews(TestCase):
'context': {
'course_id': 'foo/bar/baz',
'org_id': 'foo',
'session': sentinel.session,
},
}
self.mock_tracker.send.assert_called_once_with(expected_event)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment