Exemplo n.º 1
0
    def test_timeline_command_paginated(self):
        status1 = self._tweet('igorsobreira', 'Just a simple tweet')
        status2 = self._tweet('somebody', 'Just another tweet')

        api = self.mocker.mock()
        api.home_timeline(page=1)
        self.mocker.result([status1])
        api.home_timeline(page=2)
        self.mocker.result([status2])

        self.mocker.replay()

        commands = TwitterCommands(api)
        text1, html1 = commands.home_timeline()
        text2, html2 = commands.home_timeline(page=2)

        self.mocker.verify()
        
        expected_html1 =  '<a href="http://twitter.com/igorsobreira">@igorsobreira</a>: '
        expected_html1 += 'Just a simple tweet'
        
        assert "@igorsobreira: Just a simple tweet" == text1
        assert expected_html1 == html1

        expected_html2 = '<a href="http://twitter.com/somebody">@somebody</a>: '
        expected_html2 += 'Just another tweet'
        
        assert "@somebody: Just another tweet" == text2
        assert expected_html2 == html2
Exemplo n.º 2
0
    def test_timeline_command(self):
    
        author1 = self.mocker.mock()
        author1.name
        self.mocker.result("igorsobreira")

        status1 = self.mocker.mock()
        status1.author
        self.mocker.result(author1)
        status1.text
        self.mocker.result("Just a simple tweet")
        
        author2 = self.mocker.mock()
        author2.name
        self.mocker.result("somebody")

        status2 = self.mocker.mock()
        status2.author
        self.mocker.result(author2)
        status2.text
        self.mocker.result("Just another tweet")

        api = self.mocker.mock()
        api.home_timeline()
        self.mocker.result([status1, status2])
        
        self.mocker.replay()

        commands = TwitterCommands(api)
        result = commands.home_timeline()
        
        self.mocker.verify()
        assert "@igorsobreira: Just a simple tweet\n\n@somebody: Just another tweet" == result
Exemplo n.º 3
0
    def test_timeline_command(self):
        status1 = self._tweet('igorsobreira', 'Just a simple tweet')
        status2 = self._tweet('somebody', 'Just another tweet')

        api = self.mocker.mock()
        api.home_timeline(page=1)
        self.mocker.result([status1, status2])

        self.mocker.replay()

        commands = TwitterCommands(api)
        text, html = commands.home_timeline()

        self.mocker.verify()
        assert '@igorsobreira: Just a simple tweet\n\n@somebody: Just another tweet' == text
        
        expected_html =  '<a href="http://twitter.com/igorsobreira">@igorsobreira</a>: '
        expected_html += 'Just a simple tweet<br/><br/>'
        expected_html += '<a href="http://twitter.com/somebody">@somebody</a>: '
        expected_html += 'Just another tweet'
        
        assert expected_html == html