-
Notifications
You must be signed in to change notification settings - Fork 0
/
unittest_numbot.py
123 lines (94 loc) · 3.34 KB
/
unittest_numbot.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
# -*- coding: utf-8; -*-
import unittest
import time
from fb_api import FBBot
from gg_api import GGBot
from gg_fetcher import GGFetcher
from gg_matcher import GGMatcher
from fb_fetcher import FBFetcher
from fb_searcher import FBSearcher
__author__ = "Wen-Hao Lee"
__email__ = "[email protected]"
__copyright__ = "Copyright 2014, Numnum"
class FBBotTestCase(unittest.TestCase):
def setUp(self):
self.fb_bot = FBBot()
def tearDown(self):
pass
def testFetchUserName(self):
resp = self.fb_bot.fetch(100000818222236)
assert resp['username'] == 'wing3s'
def testFetchCategoryName(self):
resp = self.fb_bot.fetch(470781916349719)
assert resp['category_list'][0]['name'] == "Fondue Restaurant"
def testSearch(self):
params = {
'q': 'coffee',
'type': 'place',
'center': '37.76,-122.427',
'distance': 1000}
resp = self.fb_bot.search(params)
assert resp[0]['category'] == 'Local business'
def testSearchPlace(self):
result = self.fb_bot._search_place('restaurant', 25.04, 121.51)
names = [x['name'] for x in result]
assert 'Pondok Pitaya Hotel And Restaurant' in names
def testSearchRestaurants(self):
result = self.fb_bot.search_restaurant(25.035, 121.569)
names = [x['name'] for x in result]
found = False
for name in names:
if 'Lawry' in name:
found = True
assert found
class GGBotTestCase(unittest.TestCase):
def setUp(self):
self.gg_bot = GGBot()
def tearDown(self):
pass
def testFetch(self):
resp = self.gg_bot.fetch(
"CpQBjAAAAGsFtkhTZsXWQ4YaAQX68OL"
"yKhVRGRupRmXTqE9iwDnAblXxeasK9a"
"1h2Z3CEw3olLEPF5gPIPlX4xiCc17-oj"
"tH3WAd0MApjA2WPPLG1RpokYSaKwQJno"
"6MZrvkqI4snTsVDhckQsWRN2y3jUm49b"
"_aDNdDqpEfuJNCQ0k5NN4oPe19wpqe7U0"
"TyDXYYWshOhIQzDymLziVOlAVYVYO6RGQF"
"hoUAVcqXPyiFkG1ABx6ySG7u0iTVY0")
ggid = "2a9edf0faa231d917726ac14622a4a464691c15a"
assert resp['id'] == ggid
def testSearchNearby(self):
resp = self.gg_bot.search_nearby(
"麥味登林口信義店",
"restaurant",
25.082706,
121.374712)
ggid = "2a9edf0faa231d917726ac14622a4a464691c15a"
assert resp[0]['id'] == ggid
class FBSearcherTestCase(unittest.TestCase):
def setUp(self):
self.fb_searcher = FBSearcher('dev')
def testSearchLocations(self):
updated = self.fb_searcher.search_locations(5)
assert updated > 0
class FBFetcherTestCase(unittest.TestCase):
def setUp(self):
self.fb_fetcher = FBFetcher('dev')
def testUpdateShops(self):
updated = self.fb_fetcher.update_shops_info(3)
assert updated == 3
class GGMatcherTestCase(unittest.TestCase):
def setUp(self):
self.gg_matcher = GGMatcher('dev')
def testMatchShops(self):
matched = self.gg_matcher.match_fb_shops(5)
assert (matched > 1 and matched <= 5)
class GGFetcherTestCase(unittest.TestCase):
def setUp(self):
self.gg_fetcher = GGFetcher('dev')
def testUpdateShops(self):
updated = self.gg_fetcher.update_shops_info(3)
assert updated == 3
if __name__ == '__main__':
unittest.main()