-
Notifications
You must be signed in to change notification settings - Fork 255
Expand file tree
/
Copy pathsearch.py
More file actions
31 lines (25 loc) · 1.29 KB
/
search.py
File metadata and controls
31 lines (25 loc) · 1.29 KB
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
# encoding: utf-8
from zhihu import Search
import unittest
import time
class SearchTestCase(unittest.TestCase):
def setUp(self):
self.search = Search()
def test_search_question(self):
time.sleep(1)
ids, titles = self.search.search_question('python', 20)
self.assertEqual(len(ids), len(titles), msg="The numbers of IDs and titles we get should be the same.")
self.assertEqual(len(ids), 20, msg="We should get 20 IDs.")
self.assertEqual(len(ids), len(set(ids)), msg="All the IDs should be unique.")
def test_search_people(self):
time.sleep(1)
ids, names = self.search.search_people('python', 20)
self.assertEqual(len(ids), len(names), msg="The numbers of IDs and names we get should be the same.")
self.assertEqual(len(ids), 20, msg="We should get 20 IDs.")
self.assertEqual(len(ids), len(set(ids)), msg="All the IDs should be unique.")
def test_search_topic(self):
time.sleep(1)
ids, topics = self.search.search_topic('python', 20)
self.assertEqual(len(ids), len(topics), msg="The numbers of IDs and topics we get should be the same.")
self.assertEqual(len(ids), 20, msg="We should get 20 IDs.")
self.assertEqual(len(ids), len(set(ids)), msg="All the IDs should be unique.")