Пример #1
0
    def test_tweet_nothing_on_api_failure(self, get_settings, get_api):
        get_settings.return_value = self.create_settings()

        get_api.return_value = get_api
        get_api.side_effect = Exception

        assert tweet('foo') is None
Пример #2
0
    def test_tweet_nothing_on_api_failure(self, get_settings, get_api):
        get_settings.return_value = self.create_settings()

        get_api.return_value = get_api
        get_api.side_effect = Exception

        assert tweet('foo') is None
Пример #3
0
    def test_tweet_returns_status_url(self, get_settings, get_api, settings):
        settings.TWITTER_USERNAME = '******'
        get_settings.return_value = self.create_settings()

        get_api.return_value = get_api
        get_api.update_status.return_value = Mock(id=12345)

        # we don't patch settings
        assert tweet('foo') == 'http://twitter.com/foobar/status/12345'
Пример #4
0
    def test_tweet_returns_status_url(self, get_settings, get_api, settings):
        settings.TWITTER_USERNAME = '******'
        get_settings.return_value = self.create_settings()

        get_api.return_value = get_api
        get_api.update_status.return_value = Mock(id=12345)

        # we don't patch settings
        assert tweet('foo') == 'http://twitter.com/foobar/status/12345'
Пример #5
0
def test_tweet_handles_unicode(api):
    settings.TWITTER_CONSUMER_KEY = 'foo'
    settings.TWITTER_CONSUMER_SECRET = 'foo'
    settings.TWITTER_OAUTH_TOKEN = 'foo'
    settings.TWITTER_OAUTH_TOKEN_SECRET = 'foo'
    settings.TWITTER_USERNAME = '******'

    api.return_value = api
    api.update_status.return_value = Mock(id=123456789)

    assert twitter.tweet(u'☃') == 'http://twitter.com/helgabot/status/123456789'
Пример #6
0
def test_tweet_handles_unicode(api):
    settings.TWITTER_CONSUMER_KEY = 'foo'
    settings.TWITTER_CONSUMER_SECRET = 'foo'
    settings.TWITTER_OAUTH_TOKEN = 'foo'
    settings.TWITTER_OAUTH_TOKEN_SECRET = 'foo'
    settings.TWITTER_USERNAME = '******'

    api.return_value = api
    api.update_status.return_value = Mock(id=123456789)

    assert twitter.tweet(
        u'☃') == 'http://twitter.com/helgabot/status/123456789'
Пример #7
0
    def tweet(self, channel):
        if channel not in self.last:
            return "%(nick)s, why don't you try making one first?"

        # fives / sevens / fives
        resp = tweet("\n".join(self.last[channel]))

        # This will keep it from over tweeting
        del self.last[channel]

        if not resp:
            resp = "%(nick)s that probably did not work"

        return resp
Пример #8
0
    def tweet(self, channel):
        if channel not in self.last:
            return "%(nick)s, why don't you try making one first?"

        # fives / sevens / fives
        resp = tweet('\n'.join(self.last[channel]))

        # This will keep it from over tweeting
        del self.last[channel]

        if not resp:
            resp = '%(nick)s that probably did not work'

        return resp
Пример #9
0
    def tweet_last(self, channel):
        # *args here because we call it like add_line/add_use_line/remove_line
        # TODO: There should be a twitter extension to do this bit
        if channel not in self.last:
            return "%(nick)s, why don't you try making one first?"

        # fives / sevens / fives
        resp = tweet(' / '.join(self.last[channel]))

        # This will keep it from over tweeting
        del self.last[channel]

        if not resp:
            resp = '%(nick)s that probably did not work'

        return resp
Пример #10
0
    def tweet_oh(self, nick, channel):
        if nick == self.bot.nick:
            return "Nobody needs to know what I say"

        last_message = self.messages[channel].get(nick, '')

        if not last_message:
            return "%s hasn't said anything yet" % nick
        else:
            # Account for 4 characters - OH:<space>
            msg = "OH: %s" % message_max(last_message, 136)
            resp = tweet(msg)

            # No over tweeting
            try:
                del self.messages[channel][nick]
            except KeyError:
                # Hey, we tried
                pass

            if not resp:
                resp = '%(nick)s that probably did not work'

            return resp
Пример #11
0
    def tweet_oh(self, nick, channel):
        if nick == self.bot.nick:
            return "Nobody needs to know what I say"

        last_message = self.messages[channel].get(nick, '')

        if not last_message:
            return "%s hasn't said anything yet" % nick
        else:
            # Account for 4 characters - OH:<space>
            msg = "OH: %s" % message_max(last_message, 136)
            resp = tweet(msg)

            # No over tweeting
            try:
                del self.messages[channel][nick]
            except KeyError:
                # Hey, we tried
                pass

            if not resp:
                resp = '%(nick)s that probably did not work'

            return resp
Пример #12
0
def test_tweet_with_improperly_configured_settings(configured, message_140):
    configured.return_value = False
    twitter.tweet('foobar')
    assert not message_140.called
Пример #13
0
def test_tweet_with_improperly_configured_settings(configured, message_140):
    configured.return_value = False
    twitter.tweet('foobar')
    assert not message_140.called