コード例 #1
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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'
コード例 #2
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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'
コード例 #3
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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)
コード例 #4
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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)
コード例 #5
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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')
コード例 #6
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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 ☃')
コード例 #7
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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')
コード例 #8
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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')
コード例 #9
0
ファイル: test_poems.py プロジェクト: carriercomm/helga
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')
コード例 #10
0
ファイル: test_poems.py プロジェクト: carriercomm/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')
コード例 #11
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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')
コード例 #12
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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 ☃')
コード例 #13
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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')
コード例 #14
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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')
コード例 #15
0
ファイル: test_poems.py プロジェクト: michaelorr/helga
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')
コード例 #16
0
ファイル: test_poems.py プロジェクト: michaelorr/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')