Skip to content

Commit bc14772

Browse files
committed
Adding a test that illustrates how to start a new user session. intercom#73
1 parent 37f06b1 commit bc14772

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/integration/issues/test_73.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
How do I record when a User has started a new session?
4+
"""
5+
6+
import os
7+
import unittest
8+
from intercom import Intercom
9+
from intercom import User
10+
11+
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
12+
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
13+
14+
15+
class Issue73Test(unittest.TestCase):
16+
17+
def test(self):
18+
user = User.create(email='bingo@example.com')
19+
# store current session count
20+
session_count = user.session_count
21+
22+
# register a new session
23+
user.new_session = True
24+
user.save()
25+
26+
# count has increased by 1
27+
self.assertEquals(session_count + 1, user.session_count)
28+
29+
# register a new session
30+
user.new_session = True
31+
user.save()
32+
33+
# count has increased by 1
34+
self.assertEquals(session_count + 2, user.session_count)

0 commit comments

Comments
 (0)