-
Notifications
You must be signed in to change notification settings - Fork 255
Expand file tree
/
Copy pathquestion.py
More file actions
31 lines (23 loc) · 1.11 KB
/
question.py
File metadata and controls
31 lines (23 loc) · 1.11 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
# encoding: utf-8
import unittest
from zhihu import Question
class QuestionTestCase(unittest.TestCase):
def test_follow_question_with_id(self):
data = Question(id=32096743).follow_question()
self.assertEqual({"is_following": True}, data)
def test_unfollow_question_with_id(self):
data = Question(id=32096743).unfollow_question()
self.assertEqual({"is_following": False}, data)
def test_follow_question_with_url(self):
data = Question(url='https://www.zhihu.com/question/58684385').follow_question()
self.assertEqual({"is_following": True}, data)
def test_follow_question_with_answer_url(self):
"""
也支持回答的URL,因为从回答中也能找到问题的ID
:return:
"""
data = Question(url='https://www.zhihu.com/question/59001738/answer/160832685').follow_question()
self.assertEqual({"is_following": True}, data)
def test_unfollow_question_with_url(self):
data = Question(url='https://www.zhihu.com/question/58684385').unfollow_question()
self.assertEqual({"is_following": False}, data)