本文整理匯總了Python中repository.Repository.get_public_time_line方法的典型用法代碼示例。如果您正苦於以下問題:Python Repository.get_public_time_line方法的具體用法?Python Repository.get_public_time_line怎麽用?Python Repository.get_public_time_line使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類repository.Repository
的用法示例。
在下文中一共展示了Repository.get_public_time_line方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestService
# 需要導入模塊: from repository import Repository [as 別名]
# 或者: from repository.Repository import get_public_time_line [as 別名]
#.........這裏部分代碼省略.........
def test_multiple_users_can_login_to_the_service(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
self.service.register_user('Tim', 'House', 'thouse', 'pass')
self.service.login('bhill', 'qwerty')
self.service.login('thouse', 'pass')
expected = 2
actual = len(self.repository.tokens)
self.assertEqual(expected, actual)
# user logout
def test_a_logged_in_user_can_logout(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
token = self.service.login('bhill', 'qwerty')
expected = True
actual = self.service.logout('bhill')
self.assertEqual(expected, actual)
self.assertFalse(token in self.repository.tokens)
def test_only_logged_in_users_can_be_logged_out(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
self.service.register_user('Tim', 'House', 'thouse', 'pass')
self.service.login('bhill', 'qwerty')
with self.assertRaises(ValueError):
self.service.logout('thouse')
# user post creation
def test_logged_in_user_can_post(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
token = self.service.login('bhill', 'qwerty')
self.service.post(token, 'this is my post')
expected = ['this is my post']
actual = self.repository.get_public_time_line('bhill')
self.assertEqual(expected, actual)
def test_logged_out_user_cannot_post(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
token = 'abcdef'
with self.assertRaises(ValueError):
self.service.post(token, 'this is my post')
# followint users
def test_logged_in_user_can_follow_other_users(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
self.service.register_user('Ann', 'White', 'awhite', 'secret')
self.service.register_user('Tim', 'House', 'thouse', 'pass')
token = self.service.login('bhill', 'qwerty')
self.service.follow(token, 'awhite')
self.service.follow(token, 'thouse')
expected = ['awhite', 'thouse']
actual = self.repository.users['bhill'].following
self.assertEqual(expected, actual)
def test_logged_in_user_cannot_follow_another_user_twice(self):
self.service.register_user('Bill', 'Hill', 'bhill', 'qwerty')
self.service.register_user('Ann', 'White', 'awhite', 'secret')
self.service.register_user('Tim', 'House', 'thouse', 'pass')
token = self.service.login('bhill', 'qwerty')
self.service.follow(token, 'awhite')
self.service.follow(token, 'thouse')
with self.assertRaises(ValueError):
self.service.follow(token, 'thouse')
def test_logged_in_user_cannot_follow_non_existing_user(self):