def test_ReturnEmptyWeiboResultWhenAPIReturnNoResult(self): weiboResult = Mock() weiboResult.statuses = [] weiboapiMock = Mock() weiboapiMock.statuses.user_timeline.get = Mock(return_value=weiboResult) target = SinaWeiboAPI(WeiboAPIModuleMock(weiboapiMock), self._virtualBrowser, None, None, '', None, None) result = target.getWeibo(None, 100) self.assertEquals(len(result), 0)
def test_ReturnEmptyWhenNoUser(self): emptyUserResult = Mock() emptyUserResult.users = [] emptyUserResult.next_cursor = 0 weiboapiMock = Mock() weiboapiMock.friendships.friends.get = Mock(return_value=emptyUserResult) target = SinaWeiboAPI(WeiboAPIModuleMock(weiboapiMock), self._virtualBrowser, None, None, '', None, None) result = target.getFollowingUser(None) self.assertEquals(len(result), 0)
def _processDefaultGetWeibo(self, maxWeiboCount): target = SinaWeiboAPI(WeiboAPIModuleMock(self._defaultweiboapiMock), self._virtualBrowser, None, None, '', None, None) return target.getWeibo(None, maxWeiboCount)
def _assertGetAllUser(self, count): for i in range(0, count): self._userList.append(Mock()) target = SinaWeiboAPI(WeiboAPIModuleMock(self._defaultweiboapiMock), self._virtualBrowser, None, None, '', None, None) result = target.getFollowingUser(None) self.assertEquals(len(result), count)