limbo icon indicating copy to clipboard operation
limbo copied to clipboard

needed more business cat

Open dguido opened this issue 9 years ago • 3 comments

This PR adds a simple business cat plugin. It watches for any text matching known business jargon and responds with a randomly chosen business cat image. Jargon and images were taken from hubot-business-cat (MIT licensed).

dguido avatar Jan 20 '15 04:01 dguido

Not ignoring you, btw, I just merged the tests branch, but I don't have plugin tests yet and I don't trust PRs until I do. Coming soon!

llimllib avatar Jan 23 '15 16:01 llimllib

Oh cool you have tests now. I should start using those.

dguido avatar Jan 23 '15 16:01 dguido

I spot checked ~6 of the imgur images and all their links still work! (go imgur!)


I started writing what a test file for plugin would be but I got hung up on a question: was this supposed to use re.match? ie: are we supposed to only match on input text that starts with a trigger phrase? It seems like re.search may have been the intended target (so we match if the trigger phrase is anywhere in the input text).

Certain triggers definitely seem like re.search was the intended behavior. See this trigger:

    "(\\W|^)buy(\\s|-)in",

That doesn't make much sense with re.match, but does with re.search.


Anyway, here's a start of what the plugin test file might look like (currently failing, see comment in file):

import os
import sys

DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(DIR, '../../limbo/plugins'))

from business_cat import on_message

def __we_get_response(text):
    ret = on_message({"text": text}, None)
    assert '.jpg' in ret

def test_business_cat():
    __we_get_response(u'action item')
    __we_get_response(u'action items')
    __we_get_response(u'action items extra words')
    __we_get_response(u'action items extra words')

    __we_get_response(u'buy in')

    ### these currently fail, due to re.match only matching on the start of an input phrase
    __we_get_response(u'get buy in')
    __we_get_response(u'get buy-in')
    __we_get_response(u'get buy-in extra words')

topher200 avatar Oct 09 '17 09:10 topher200