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'
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)
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)
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')
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 ☃')
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')
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')
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')
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')