-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_get_filter_results.py
351 lines (252 loc) · 11 KB
/
test_get_filter_results.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import unittest
import twitterverse_functions as tf
EMPTY_LIST = []
SINGLE_USER = ['tomCruise']
DOUBLE_USER = ['tomCruise', 'PerezHilton']
NO_FILTER_EXAMPLE = {}
NAME_EXAMPLE1 = {'name-includes': 'Cruise'}
NAME_EXAMPLE2 = {'name-includes': 'Johnny'}
LOCATION_EXAMPLE1 = {'location-includes': 'Los Angeles'}
LOCATION_EXAMPLE2 = {'location-includes': 'Saudi Arabia'}
FOLLOWERS_EXAMPLE1 = {'followers': 'PerezHilton'}
FOLLOWERS_EXAMPLE2 = {'followers': 'bennyJJJ'}
FOLLOWING_EXAMPLE1 = {'following': 'katieH'}
FOLLOWING_EXAMPLE2 = {'following': 'benLOL'}
MULTIPLE_EXAMPLE1 = {'name-includes': 'Cruise',
'location-includes': 'Los Angeles'}
MULTIPLE_EXAMPLE2 = {'following': 'NicoleKidman', 'following': 'katieH'}
MULTIPLE_EXAMPLE3 = {'followers': 'PerezHilton', 'following': 'benLOL'}
MULTIPLE_EXAMPLE4 = {'name-includes': 'Johnny', 'followers': 'bennyJJJ'}
class TestGetFilterResults(unittest.TestCase):
'''Example unittest test methods for get_filter_results'''
#No filter tests
def test_filter_example_1(self):
'''Test get_filter_results with an empty user list and no filters.'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, EMPTY_LIST
, NO_FILTER_EXAMPLE)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_2(self):
'''Test get_filter_results with a single user and no filters.'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, NO_FILTER_EXAMPLE)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_3(self):
'''Test get_filter_results with multiple users and no filters.'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, NO_FILTER_EXAMPLE)
expected = DOUBLE_USER
self.assertEqual(expected, actual)
#Name-Includes Tests
def test_filter_example_4(self):
'''Test get_filter_results with an empty user list and name-includes
filter.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, EMPTY_LIST
, NAME_EXAMPLE1)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_5(self):
'''Test get_filter_results with a single user and name-includes
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, NAME_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_6(self):
'''Test get_filter_results with a single user and name-includes
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, NAME_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_7(self):
'''Test get_filter_results with multiple users and name-includes
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, NAME_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_8(self):
'''Test get_filter_results with multiple users and name-includes
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, NAME_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
#Location-includes tests
def test_filter_example_9(self):
'''Test get_filter_results with no users and location-includes
filter.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, EMPTY_LIST
, LOCATION_EXAMPLE1)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_10(self):
'''Test get_filter_results with single user and location-includes
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, LOCATION_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_11(self):
'''Test get_filter_results with single user and location-includes
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, LOCATION_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_12(self):
'''Test get_filter_results with multiple users and location-includes
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, LOCATION_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_13(self):
'''Test get_filter_results with multiple users and location-includes
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, LOCATION_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
#Followers tests
def test_filter_example_14(self):
'''Test get_filter_results with no users and followers filter.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, EMPTY_LIST
, FOLLOWERS_EXAMPLE1)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_15(self):
'''Test get_filter_results with a single user and followers
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, FOLLOWERS_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_16(self):
'''Test get_filter_results with a single user and followers
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, FOLLOWERS_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_17(self):
'''Test get_filter_results with multiple users and followers
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, FOLLOWERS_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_18(self):
'''Test get_filter_results with multiple users and followers
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, FOLLOWERS_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
#Following tests
def test_filter_example_19(self):
'''Test get_filter_results with no users and following filter.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, EMPTY_LIST
, FOLLOWING_EXAMPLE1)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_20(self):
'''Test get_filter_results with a single user and following
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, FOLLOWING_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_21(self):
'''Test get_filter_results with a single user and following
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, FOLLOWING_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_22(self):
'''Test get_filter_results with multiple users and following
filter that is met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, FOLLOWING_EXAMPLE1)
expected = DOUBLE_USER
self.assertEqual(expected, actual)
def test_filter_example_23(self):
'''Test get_filter_results with multiple users and following
filter that is not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, FOLLOWING_EXAMPLE2)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
#Multiple filter tests
def test_filter_example_24(self):
'''Test get_filter_results with no users and multiple filters.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, EMPTY_LIST
, MULTIPLE_EXAMPLE1)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_25(self):
'''Test get_filter_results with single user and multiple
filters that are both met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, MULTIPLE_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_26(self):
'''Test get_filter_results with single user and multiple
filters that are met and then not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, SINGLE_USER
, MULTIPLE_EXAMPLE3)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
def test_filter_example_27(self):
'''Test get_filter_results with multiple users and multiple
filters that are both met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, MULTIPLE_EXAMPLE2)
expected = DOUBLE_USER
self.assertEqual(expected, actual)
def test_filter_example_28(self):
'''Test get_filter_results with multiple users and multiple
filters that only one user will meet.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, MULTIPLE_EXAMPLE1)
expected = SINGLE_USER
self.assertEqual(expected, actual)
def test_filter_example_29(self):
'''Test get_filter_results with multiple users and multiple
filters that are both not met.
'''
actual = tf.get_filter_results(tf.HANDOUT_DATA, DOUBLE_USER
, MULTIPLE_EXAMPLE4)
expected = EMPTY_LIST
self.assertEqual(expected, actual)
if __name__ == '__main__':
unittest.main(exit=False)