示例#1
0
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'
示例#2
0
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'
示例#3
0
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'
示例#4
0
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'
示例#5
0
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'
示例#6
0
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"
示例#7
0
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'
示例#8
0
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"