Skip to content

Commit b7432cb

Browse files
committed
break up tests
1 parent 432312d commit b7432cb

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

requirements-testing.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pytest~=7.1.2
1+
pytest~=4.6.11
22
responses~=0.13.3
33
more-itertools==8.10.0 ; python_version=='3.5' # more-itertools added some f-strings after this.
4-
typing; python_version>='3.7' and python_version<'3.10' # To work around CI fail.
4+
typing; python_version>='3.4' and python_version<'3.5' # To work around CI fail.

test_mixpanel.py

+29-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def clear(self):
3030
self.log = []
3131

3232

33-
class TestMixpanel:
33+
class TestMixpanelBase:
3434
TOKEN = '12345'
3535

3636
def setup_method(self, method):
@@ -39,6 +39,9 @@ def setup_method(self, method):
3939
self.mp._now = lambda: 1000.1
4040
self.mp._make_insert_id = lambda: "abcdefg"
4141

42+
43+
class TestMixpanelTracking(TestMixpanelBase):
44+
4245
def test_track(self):
4346
self.mp.track('ID', 'button press', {'size': 'big', 'color': 'blue', '$insert_id': 'abc123'})
4447
assert self.consumer.log == [(
@@ -122,6 +125,9 @@ def test_track_meta(self):
122125
}
123126
)]
124127

128+
129+
class TestMixpanelPeople(TestMixpanelBase):
130+
125131
def test_people_set(self):
126132
self.mp.people_set('amq', {'birth month': 'october', 'favorite color': 'purple'})
127133
assert self.consumer.log == [(
@@ -284,6 +290,26 @@ def test_people_set_created_date_datetime(self):
284290
}
285291
)]
286292

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+
287313
def test_alias(self):
288314
# More complicated since alias() forces a synchronous call.
289315

@@ -333,22 +359,8 @@ def test_merge(self):
333359
('my_good_api_key', 'my_secret'),
334360
)]
335361

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):
352364

353365
def test_group_set(self):
354366
self.mp.group_set('company', 'amq', {'birth month': 'october', 'favorite color': 'purple'})

0 commit comments

Comments
 (0)