Skip to content

Commit

Permalink
fix some of the tests broken by make test-network
Browse files Browse the repository at this point in the history
Fixes some of llimllib#131
  • Loading branch information
tbrown-wordstream committed Oct 13, 2017
1 parent f9f2a7d commit 0d97ae2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 24 deletions.
5 changes: 4 additions & 1 deletion test/test_plugins/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import sys

import six

from .utils import VCR

DIR = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -12,4 +14,5 @@
def test_commit():
with VCR.use_cassette('test/fixtures/commit.yaml'):
ret = on_message({"text": u"!commit"}, None)
assert 'stuff' in ret
assert isinstance(ret, six.string_types), ret
assert len(ret) > 0
7 changes: 2 additions & 5 deletions test/test_plugins/test_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@

from gif import on_message

# The set of valid gifs given the bananas fixture
bananas_gifs = ['http://byt.wpengine.netdna-cdn.com/wp-content/uploads/2014/09/banana-dolphin-and-boy.gif', 'http://joedale.typepad.com/photos/uncategorized/2008/05/29/bananas.gif', 'http://orig04.deviantart.net/a8fc/f/2012/269/a/b/i_heart_banana_by_mnrart-d5fyx04.gif', 'http://images2.wikia.nocookie.net/illogicopedia/images/3/31/Dancing_Banana.gif', 'http://media.giphy.com/media/PlwtdKszlxyLK/giphy.gif', 'https://s-media-cache-ak0.pinimg.com/originals/81/36/86/813686513bb0ea580e9891fc15ec7678.jpg', 'http://www.webweaver.nu/clipart/img/misc/food/fruit/bunch-of-bananas.gif', 'http://www.animatedimages.org/data/media/330/animated-banana-image-0039.gif', 'http://www.rockinghamremembered.com/images/bananas.gif', 'http://ak-hdl.buzzfed.com/static/2015-09/11/13/imagebuzz/webdr07/anigif_optimized-6124-1441992418-1.gif', 'http://www.picgifs.com/graphics/b/bananas/graphics-bananas-761495.gif', 'http://volweb.utk.edu/SCHOOL/sweetwjh/dancing%20banana.gif', 'http://i.imgur.com/LQzD19d.gif', 'http://media.giphy.com/media/LldwJVCUlhRmg/giphy.gif', 'http://images5.fanpop.com/image/photos/30600000/Banana-gif-bananas-30667445-140-140.gif', 'http://www.sevenoaksart.co.uk/images/banana2.gif', 'http://ww2.valdosta.edu/~kabehland/gobananas.gif', 'http://www.comevisit.com/chuckali/bananas.gif', 'http://media.giphy.com/media/1MqvxsrhMHrGw/giphy.gif', 'https://strengthandsweets.files.wordpress.com/2014/01/bananadance.gif']

def test_gif():
with VCR.use_cassette('test/fixtures/gif_bananas.yaml'):
ret = on_message({"text": u"!gif bananas"}, None)
assert ret in bananas_gifs, "{0} not in {1}".format(ret, bananas_gifs)
assert '.gif' in ret, ret

def test_unicode():
with VCR.use_cassette('test/fixtures/gif_unicode.yaml'):
ret = on_message({"text": u"!gif Mötörhead"}, None)
_ = on_message({"text": u"!gif Mötörhead"}, None)
# not blowing up == success, for our purposes
7 changes: 3 additions & 4 deletions test/test_plugins/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ def dicteq(a, b):

def test_basic():
with VCR.use_cassette('test/fixtures/github_issues.yaml'):
ret = on_message({"text": u"!hub issue 5 -r llimllib/limbo", "channel": "test_channel"}, SERVER)
#import ipdb; ipdb.set_trace()
_ = on_message({"text": u"!hub issue 5 -r llimllib/limbo", "channel": "test_channel"}, SERVER)
expected = {
u'author_icon': u'https://avatars.githubusercontent.com/u/7150?v=3',
u'author_icon': u'https://avatars3.githubusercontent.com/u/7150?v=4',
u'author_link': u'https://github.com/llimllib',
u'author_name': u'llimllib',
u'color': u'good',
u'fallback': u'Create an emoji translator',
u'text': u'i.e. if you type "I love to eat bananas", the plugin does *something* to try and convert that into a string of emoji. It probably involves a list of synonyms? Maybe even a word model? Or it does something really simple? I don\'t know, but it would be an awesome feature.',
u'text': u'i.e. if you type "I love to eat bananas", the plugin does _something_ to try and convert that into a string of emoji. It probably involves a list of synonyms? Maybe even a word model? Or it does something really simple? I don\'t know, but it would be an awesome feature.\n',
u'title': u'[5] Create an emoji translator',
u'title_link': u'https://github.com/llimllib/limbo/issues/5'
}
Expand Down
7 changes: 2 additions & 5 deletions test/test_plugins/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@

from image import on_message, unescape

# The set of valid images given the bananas fixture
bananas_images = ['http://cdn1.medicalnewstoday.com/content/images/articles/271157-bananas.jpg', 'http://runhaven.com/wp-content/uploads/minion-bananas.jpg', 'https://www.organicfacts.net/wp-content/uploads/2013/05/Banana21.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Bananas.jpg/1024px-Bananas.jpg', 'http://dreamatico.com/data_images/banana/banana-3.jpg', 'http://www.esbtrib.com/wp-content/uploads/2015/09/bananas1.jpeg', 'http://weknowyourdreams.com/images/banana/banana-07.jpg', 'http://saltmarshrunning.com/wp-content/uploads/2014/09/bananasf.jpg', 'https://www.organicfacts.net/wp-content/uploads/2013/05/Banana3.jpg', 'http://bed56888308e93972c04-0dfc23b7b97881dee012a129d9518bae.r34.cf1.rackcdn.com/sites/default/files/imagecache/310_square/bananas_1.jpg', 'http://www.fitnessworksmb.com/wp-content/uploads/banana.jpg', 'https://media.licdn.com/mpr/mpr/shrinknp_800_800/AAEAAQAAAAAAAARXAAAAJGU2NGE1NzUzLTgxNzYtNDZiZC05YWY1LWQ4ZWE0OTk0NDY2Mw.jpg', 'https://charinacabswords.files.wordpress.com/2015/07/health-benefits-of-bananas.jpg', 'http://www.unitedfreshservices.com/content/01-services_bananen_rijperij/banana_ripening.jpg', 'http://parentinghealthybabies.com/wp-content/uploads/2013/03/bananas.jpg', 'http://foodmatters.tv/images/bananas.jpg', 'http://a3145z3.americdn.com/wp-content/uploads/2014/03/10-amazing-facts-bananas.jpg', 'http://www.popsci.com/sites/popsci.com/files/styles/large_1x_/public/import/2014/bananas-flickr-ian-ransley-design-dog-ccby20.jpg?itok\\0754G6KHch5', 'http://nobacks.com/wp-content/uploads/2014/11/Banana-21.png', 'http://i.telegraph.co.uk/multimedia/archive/01423/banana_1423728c.jpg']

def test_image():
with VCR.use_cassette('test/fixtures/image_bananas.yaml'):
ret = on_message({"text": u"!image bananas"}, None)
assert ret in bananas_images, "{0} not in {1}".format(ret, bananas_images)
assert '.jpg' in ret, ret

def test_unicode():
with VCR.use_cassette('test/fixtures/image_unicode.yaml'):
ret = on_message({"text": u"!image Mötörhead"}, None)
_ = on_message({"text": u"!image Mötörhead"}, None)
# not blowing up == success, for our purposes
8 changes: 3 additions & 5 deletions test/test_plugins/test_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
def test_apple():
with VCR.use_cassette('test/fixtures/stock_apple.yaml'):
ret = on_message({"text": u"$aapl"}, None)
assert ':chart_with_upwards_trend:' in ret
assert 'Apple Inc.' in ret
assert '130.41' in ret
assert '+1.62' in ret
assert ':chart_with_' in ret, ret
assert 'Apple Inc.' in ret, ret

def test_nonexistent():
with VCR.use_cassette('test/fixtures/stock_none'):
Expand All @@ -30,7 +28,7 @@ def test_unicode():
def test_multiple():
with VCR.use_cassette('test/fixtures/stock_multiple.yaml'):
ret = on_message({"text": u"$goog $aapl"}, None)
assert 'Google Inc' in ret
assert 'Alphabet Inc' in ret

def test_price():
with VCR.use_cassette('test/fixtures/stock_none'):
Expand Down
4 changes: 2 additions & 2 deletions test/test_plugins/test_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
def test_basic():
with VCR.use_cassette('test/fixtures/wiki_basic.yaml'):
ret = on_message({"text": u"!wiki dog"}, None)
assert "member of the canidae family" in ret
assert "Canis familiaris" in ret
assert "http://en.wikipedia.org/wiki/Dog" in ret

def test_unicode():
with VCR.use_cassette('test/fixtures/wiki_unicode.yaml'):
ret = on_message({"text": u"!wiki नेपाल"}, None)
_ = on_message({"text": u"!wiki नेपाल"}, None)
# not blowing up == success
4 changes: 2 additions & 2 deletions test/test_plugins/test_youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
def test_basic():
with VCR.use_cassette('test/fixtures/youtube_basic.yaml'):
ret = on_message({"text": u"!youtube live long and prosper"}, None)
assert ret == "https://www.youtube.com/watch?v=DyiWkWcR86I"
assert 'https://www.youtube.com/watch?v=' in ret, ret

def test_unicode():
with VCR.use_cassette('test/fixtures/youtube_unicode.yaml'):
ret = on_message({"text": u"!youtube 崖の上のポニョ"}, None)
_ = on_message({"text": u"!youtube 崖の上のポニョ"}, None)
# not blowing up == success

0 comments on commit 0d97ae2

Please sign in to comment.