def test_blame(db): poems.last_poem['#bots'] = ['foo', 'bar', 'baz'] db.haiku.find_one.side_effect = [ {'author': 'foo'}, {'author': u'☃'}, # Test unicode {}, # No author ] resp = poems.blame('#bots', 'me', default_author='helga') assert resp == u'The last poem was brought to you by (in order): foo, ☃, helga'
def test_blame_after_use_uses_last_author(db): poems.last_use['#bots'] = ('me', 'three') poems.last_poem['#bots'] = ['one', 'two', 'three'] db.haiku.find_one.side_effect = [ {'author': 'foo'}, {'author': 'bar'}, None ] ret = poems.blame('#bots', 'sduncan', default_author='helga') assert ret == 'The last poem was brought to you by (in order): foo, bar, me'
def test_blame_after_use_uses_last_author(db): poems.last_use['#bots'] = ('me', 'three') poems.last_poem['#bots'] = ['one', 'two', 'three'] db.haiku.find_one.side_effect = [{ 'author': 'foo' }, { 'author': 'bar' }, None] ret = poems.blame('#bots', 'sduncan', default_author='helga') assert ret == 'The last poem was brought to you by (in order): foo, bar, me'
def test_blame(db): poems.last_poem['#bots'] = ['foo', 'bar', 'baz'] db.haiku.find_one.side_effect = [ { 'author': 'foo' }, { 'author': u'☃' }, # Test unicode {}, # No author ] resp = poems.blame('#bots', 'me', default_author='helga') assert resp == u'The last poem was brought to you by (in order): foo, ☃, helga'
def test_blame_uses_default_author(db): db.haiku.find_one.side_effect = Exception poems.last_poem['#bots'] = ['foo', 'bar', 'baz'] resp = poems.blame('#bots', 'me', default_author='helga') assert resp == 'The last poem was brought to you by (in order): helga, helga, helga'
def test_blame_with_no_poem(): poems.last_poem['#bots'] = None resp = poems.blame('#bots', 'me') assert resp == "me, why don't you try making one first"