Example #1
0
def test_poems_use_subcommand(use):
    use.return_value = 'a poem'
    subcmd_args = ['use', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    use.assert_called_with(5, u'unicode ☃')
    assert poems.last_poem['#bots'] == 'a poem'
Example #2
0
def test_poems_use_subcommand(use):
    use.return_value = 'a poem'
    subcmd_args = ['use', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    use.assert_called_with(5, u'unicode ☃')
    assert poems.last_poem['#bots'] == 'a poem'
Example #3
0
def test_poems_about_or_by_subcommand(make_poem):
    args = [Mock(), '#bots', 'me', 'message', 'haiku']
    for extra in (['about', u'☃'], ['by', 'foo']):
        make_poem.reset_mock()
        poems.poems(*(args + [extra]))
        kwargs = {'poem_type': 'haiku', extra[0]: extra[1]}
        make_poem.assert_called_with(**kwargs)
Example #4
0
def test_poems_about_or_by_subcommand(make_poem):
    args = [Mock(), '#bots', 'me', 'message', 'haiku']
    for extra in (['about', u'☃'], ['by', 'foo']):
        make_poem.reset_mock()
        poems.poems(*(args + [extra]))
        kwargs = {
            'poem_type': 'haiku',
            extra[0]: extra[1]
        }
        make_poem.assert_called_with(**kwargs)
Example #5
0
def test_poems_claim_subcommand(claim):
    subcmd_args = ['claim', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    claim.assert_called_with(5, u'unicode ☃', 'me')
Example #6
0
def test_poems_remove_subcommand(remove):
    subcmd_args = ['remove', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    remove.assert_called_with(5, u'unicode ☃')
Example #7
0
def test_poems_add_subcommand(add):
    subcmd_args = ['add', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    add.assert_called_with(5, u'unicode ☃', 'me')
Example #8
0
def test_poems_tweet_subcommand(reactor):
    client = Mock()
    with pytest.raises(ResponseNotReady):
        poems.poems(client, '#bots', 'me', 'message', 'haiku', ['tweet'])
        reactor.assert_called_with(0, poems.tweet, client, '#bots', 'me')
Example #9
0
def test_poems_blame_subcommand(blame):
    poems.poems(Mock(nickname='helga'), '#bots', 'me', 'message', 'haiku', ['blame'])
    blame.assert_called_with('#bots', requested_by='me', default_author='helga')
Example #10
0
def test_poems_no_args_returns_poem(make_poem):
    poem = 'this is my poem'
    make_poem.return_value = poem
    assert poem == poems.poems(Mock(), '#bots', 'me', 'message', 'haiku', [])
    assert poem == poems.last_poem['#bots']
    make_poem.assert_called_with(poem_type='haiku')
Example #11
0
def test_poems_claim_subcommand(claim):
    subcmd_args = ['claim', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    claim.assert_called_with(5, u'unicode ☃', 'me')
Example #12
0
def test_poems_remove_subcommand(remove):
    subcmd_args = ['remove', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    remove.assert_called_with(5, u'unicode ☃')
Example #13
0
def test_poems_add_subcommand(add):
    subcmd_args = ['add', 'fives', 'unicode', u'☃']
    args = [Mock(), '#bots', 'me', 'message', 'haiku', subcmd_args]
    poems.poems(*args)
    add.assert_called_with(5, u'unicode ☃', 'me')
Example #14
0
def test_poems_tweet_subcommand(reactor):
    client = Mock()
    with pytest.raises(ResponseNotReady):
        poems.poems(client, '#bots', 'me', 'message', 'haiku', ['tweet'])
        reactor.assert_called_with(0, poems.tweet, client, '#bots', 'me')
Example #15
0
def test_poems_blame_subcommand(blame):
    poems.poems(Mock(nickname='helga'), '#bots', 'me', 'message', 'haiku',
                ['blame'])
    blame.assert_called_with('#bots',
                             requested_by='me',
                             default_author='helga')
Example #16
0
def test_poems_no_args_returns_poem(make_poem):
    poem = 'this is my poem'
    make_poem.return_value = poem
    assert poem == poems.poems(Mock(), '#bots', 'me', 'message', 'haiku', [])
    assert poem == poems.last_poem['#bots']
    make_poem.assert_called_with(poem_type='haiku')