當前位置: 首頁>>代碼示例>>Python>>正文


Python Repository.get_public_time_line方法代碼示例

本文整理匯總了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):
開發者ID:walter2,項目名稱:twitter_style_api,代碼行數:70,代碼來源:test_service.py


注:本文中的repository.Repository.get_public_time_line方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。