@@ -30,7 +30,7 @@ def clear(self):
30
30
self .log = []
31
31
32
32
33
- class TestMixpanel :
33
+ class TestMixpanelBase :
34
34
TOKEN = '12345'
35
35
36
36
def setup_method (self , method ):
@@ -39,6 +39,9 @@ def setup_method(self, method):
39
39
self .mp ._now = lambda : 1000.1
40
40
self .mp ._make_insert_id = lambda : "abcdefg"
41
41
42
+
43
+ class TestMixpanelTracking (TestMixpanelBase ):
44
+
42
45
def test_track (self ):
43
46
self .mp .track ('ID' , 'button press' , {'size' : 'big' , 'color' : 'blue' , '$insert_id' : 'abc123' })
44
47
assert self .consumer .log == [(
@@ -122,6 +125,9 @@ def test_track_meta(self):
122
125
}
123
126
)]
124
127
128
+
129
+ class TestMixpanelPeople (TestMixpanelBase ):
130
+
125
131
def test_people_set (self ):
126
132
self .mp .people_set ('amq' , {'birth month' : 'october' , 'favorite color' : 'purple' })
127
133
assert self .consumer .log == [(
@@ -284,6 +290,26 @@ def test_people_set_created_date_datetime(self):
284
290
}
285
291
)]
286
292
293
+ def test_people_meta (self ):
294
+ self .mp .people_set ('amq' , {'birth month' : 'october' , 'favorite color' : 'purple' },
295
+ meta = {'$ip' : 0 , '$ignore_time' : True })
296
+ assert self .consumer .log == [(
297
+ 'people' , {
298
+ '$time' : self .mp ._now (),
299
+ '$token' : self .TOKEN ,
300
+ '$distinct_id' : 'amq' ,
301
+ '$set' : {
302
+ 'birth month' : 'october' ,
303
+ 'favorite color' : 'purple' ,
304
+ },
305
+ '$ip' : 0 ,
306
+ '$ignore_time' : True ,
307
+ }
308
+ )]
309
+
310
+
311
+ class TestMixpanelIdentity (TestMixpanelBase ):
312
+
287
313
def test_alias (self ):
288
314
# More complicated since alias() forces a synchronous call.
289
315
@@ -333,22 +359,8 @@ def test_merge(self):
333
359
('my_good_api_key' , 'my_secret' ),
334
360
)]
335
361
336
- def test_people_meta (self ):
337
- self .mp .people_set ('amq' , {'birth month' : 'october' , 'favorite color' : 'purple' },
338
- meta = {'$ip' : 0 , '$ignore_time' : True })
339
- assert self .consumer .log == [(
340
- 'people' , {
341
- '$time' : self .mp ._now (),
342
- '$token' : self .TOKEN ,
343
- '$distinct_id' : 'amq' ,
344
- '$set' : {
345
- 'birth month' : 'october' ,
346
- 'favorite color' : 'purple' ,
347
- },
348
- '$ip' : 0 ,
349
- '$ignore_time' : True ,
350
- }
351
- )]
362
+
363
+ class TestMixpanelGroups (TestMixpanelBase ):
352
364
353
365
def test_group_set (self ):
354
366
self .mp .group_set ('company' , 'amq' , {'birth month' : 'october' , 'favorite color' : 'purple' })
0 commit comments