Exemplo n.º 1
0
    def test_direct_message_command(self):
        api = self.mocker.mock()
        api.send_direct_message(screen_name="igorsobreira", text="hello")

        self.mocker.replay()

        commands = TwitterCommands(api)
        result = commands.send_direct_message(screen_name='igorsobreira', text='hello')

        self.mocker.verify()
        assert u"Message sent" == result
Exemplo n.º 2
0
    def test_direct_message_error_when_trying_to_send_to_non_friends(self):
        api = self.mocker.mock()
        api.send_direct_message(screen_name="unknown", text="hello")
        self.mocker.throw(TweepError(u"You cannot send messages to users who are not following you."))

        self.mocker.replay()

        commands = TwitterCommands(api)
        result = commands.send_direct_message(screen_name='unknown', text='hello')

        self.mocker.verify()
        assert u"You cannot send messages to users who are not following you." == result