File size: 1,155 Bytes
0a06673
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
import unittest

import analytics


class TestModule(unittest.TestCase):

    # def failed(self):
    #     self.failed = True

    def setUp(self):
        self.failed = False
        analytics.write_key = 'testsecret'
        analytics.on_error = self.failed

    def test_no_write_key(self):
        analytics.write_key = None
        self.assertRaises(Exception, analytics.track)

    def test_no_host(self):
        analytics.host = None
        self.assertRaises(Exception, analytics.track)

    def test_track(self):
        analytics.track('userId', 'python module event')
        analytics.flush()

    def test_identify(self):
        analytics.identify('userId', {'email': '[email protected]'})
        analytics.flush()

    def test_group(self):
        analytics.group('userId', 'groupId')
        analytics.flush()

    def test_alias(self):
        analytics.alias('previousId', 'userId')
        analytics.flush()

    def test_page(self):
        analytics.page('userId')
        analytics.flush()

    def test_screen(self):
        analytics.screen('userId')
        analytics.flush()

    def test_flush(self):
        analytics.flush()