This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparse.t.py
executable file
·137 lines (130 loc) · 7.37 KB
/
parse.t.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import unittest
import random
import pprint
import datetime
from helpers import get_structured_feeds
class TestParsing(unittest.TestCase):
def setUp(self):
return
def test_parse_textfeeds(self):
feeds = [
'christopher__yang liked 8 posts. 41m',
"miebakayohannes liked familynofriends14's post. 60m",
"dustin_oharry and randy.illum liked fitzfitzfitzfitzfitz's post. 2h",
'ytong_chn liked 5 posts. 2h',
'sjs7007 started following alydiaz and uber. 4h',
'jcwangins started following jsyabc217. 5h',
'jcwangins liked 2 posts. 5h',
'yukaitu liked 2 posts. 6h',
'jorlenise started following leeoralexandra and tughuart. 6h',
'stumblex liked 8 posts. 7h',
"junjuewang liked ji_ye_'s post. 7h",
"sunny_liiiii liked changmin88's post. 11h",
"kooorio liked avant.arte's post. 12h",
"randy.illum liked j_slash_k's post. 18h",
'christopher__yang liked 5 posts. 19h',
'yemaobisutorozipterasu shared 3 posts at お肉とワイン野毛ビストロzip 19h',
'randy.illum started following barstoolsports, erikalee305 and steadmanart. 20h',
"skylar.hly liked ameliewenzhao's post. 21h",
"diraccat liked tianjinye9's post. 21h",
'lbysophia liked 4 posts. 1d',
'dustin_oharry liked 4 posts. 1d',
'skylar.hly started following thoughtcatalog, wilderpoetry and 2 others. 1d']
# TODO: fix
# liked siyuqtt's comment: 沉舟侧畔千帆过 病树前头万木春 一切都会变好的!
structured_feeds = get_structured_feeds(feeds, datetime.datetime(2018, 11, 18, 19, 15, 18, 21885))
expectation = [ { 'action': 'liked',
'count': 8,
'subject': ['christopher__yang'],
'time': datetime.datetime(2018, 11, 18, 18, 34, 18, 21885)},
{ 'action': 'liked',
'subject': ['miebakayohannes'],
'target': ['familynofriends14'],
'time': datetime.datetime(2018, 11, 18, 18, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['dustin_oharry', 'randy.illum'],
'target': ['fitzfitzfitzfitzfitz'],
'time': datetime.datetime(2018, 11, 18, 17, 15, 18, 21885)},
{ 'action': 'liked',
'count': 5,
'subject': ['ytong_chn'],
'time': datetime.datetime(2018, 11, 18, 17, 15, 18, 21885)},
{ 'action': 'started_following',
'subject': ['sjs7007'],
'target': ['alydiaz', 'uber'],
'time': datetime.datetime(2018, 11, 18, 15, 15, 18, 21885)},
{ 'action': 'started_following',
'subject': ['jcwangins'],
'target': ['jsyabc217'],
'time': datetime.datetime(2018, 11, 18, 14, 15, 18, 21885)},
{ 'action': 'liked',
'count': 2,
'subject': ['jcwangins'],
'time': datetime.datetime(2018, 11, 18, 14, 15, 18, 21885)},
{ 'action': 'liked',
'count': 2,
'subject': ['yukaitu'],
'time': datetime.datetime(2018, 11, 18, 13, 15, 18, 21885)},
{ 'action': 'started_following',
'subject': ['jorlenise'],
'target': ['leeoralexandra', 'tughuart'],
'time': datetime.datetime(2018, 11, 18, 13, 15, 18, 21885)},
{ 'action': 'liked',
'count': 8,
'subject': ['stumblex'],
'time': datetime.datetime(2018, 11, 18, 12, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['junjuewang'],
'target': ['ji_ye_'],
'time': datetime.datetime(2018, 11, 18, 12, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['sunny_liiiii'],
'target': ['changmin88'],
'time': datetime.datetime(2018, 11, 18, 8, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['kooorio'],
'target': ['avant.arte'],
'time': datetime.datetime(2018, 11, 18, 7, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['randy.illum'],
'target': ['j_slash_k'],
'time': datetime.datetime(2018, 11, 18, 1, 15, 18, 21885)},
{ 'action': 'liked',
'count': 5,
'subject': ['christopher__yang'],
'time': datetime.datetime(2018, 11, 18, 0, 15, 18, 21885)},
{ 'action': 'shared',
'count': 3,
'subject': ['yemaobisutorozipterasu'],
'target': ['お肉とワイン野毛ビストロzip'],
'time': datetime.datetime(2018, 11, 18, 0, 15, 18, 21885)},
{ 'action': 'started_following',
'subject': ['randy.illum'],
'target': ['barstoolsports', 'erikalee305', 'steadmanart'],
'time': datetime.datetime(2018, 11, 17, 23, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['skylar.hly'],
'target': ['ameliewenzhao'],
'time': datetime.datetime(2018, 11, 17, 22, 15, 18, 21885)},
{ 'action': 'liked',
'subject': ['diraccat'],
'target': ['tianjinye9'],
'time': datetime.datetime(2018, 11, 17, 22, 15, 18, 21885)},
{ 'action': 'liked',
'count': 4,
'subject': ['lbysophia'],
'time': datetime.datetime(2018, 11, 17, 19, 15, 18, 21885)},
{ 'action': 'liked',
'count': 4,
'subject': ['dustin_oharry'],
'time': datetime.datetime(2018, 11, 17, 19, 15, 18, 21885)},
{ 'action': 'started_following',
'subject': ['skylar.hly'],
'target': ['thoughtcatalog', 'wilderpoetry', 'unknown', 'unknown'],
'time': datetime.datetime(2018, 11, 17, 19, 15, 18, 21885)}]
self.assertEqual(len(feeds), len(structured_feeds))
self.assertEqual(expectation, structured_feeds)
if __name__ == '__main__':
unittest.main()