def test():
    bolt = SplitSentenceBolt()
    mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(),
                                [["Madam, I'm Adam."]])

    result = mock.run_simple_topology(None, [mock_spout, bolt],
                                      result_type=mock.LIST)
    assert_equal([['Madam,'], ["I'm"], ['Adam.']], result[bolt])
示例#2
0
def test():
    bolt = SplitSentenceBolt()
    mock_spout = mock.MockSpout(
        RandomSentenceSpout.declareOutputFields(),
        [["Madam, I'm Adam."]])

    result = mock.run_simple_topology(
        None, [mock_spout, bolt], result_type=mock.LIST)
    assert_equal([['Madam,'], ["I'm"], ['Adam.']], result[bolt])
def test():
    ss_bolt = SplitSentenceBolt()
    wc_bolt = WordCountBolt()

    mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(),
                                [["the bart the"]])

    result = mock.run_simple_topology(None, [mock_spout, ss_bolt, wc_bolt],
                                      result_type=mock.LIST)
    assert_equal([['the', 1], ['bart', 1], ['the', 2]], result[wc_bolt])
示例#4
0
def test():
    ss_bolt = SplitSentenceBolt()
    wc_bolt = WordCountBolt()

    mock_spout = mock.MockSpout(
        RandomSentenceSpout.declareOutputFields(),
        [["the bart the"]])

    result = mock.run_simple_topology(
        None,
        [mock_spout, ss_bolt, wc_bolt],
        result_type=mock.LIST)
    assert_equal([['the', 1], ['bart', 1], ['the', 2]], result[wc_bolt])
示例#5
0
def test():
    # To run this:
    # pip install nose
    # nosetests splitsentence.py
    from nose.tools import assert_equal
    bolt = SplitSentenceBolt()
    from petrel import mock
    from randomsentence import RandomSentenceSpout
    mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(), [
        ["Madam, I'm Adam."],
    ])

    result = mock.run_simple_topology(None, [mock_spout, bolt], result_type=mock.LIST)
    assert_equal([['Madam,'], ["I'm"], ['Adam.']], result[bolt])
示例#6
0
def test():
    # To run this:
    # pip install nose
    # nosetests splitsentence.py
    from nose.tools import assert_equal
    bolt = SplitSentenceBolt()
    from petrel import mock
    from randomsentence import RandomSentenceSpout
    mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(), [
        ["Madam, I'm Adam."],
    ])
    
    result = mock.run_simple_topology(None, [mock_spout, bolt], result_type=mock.LIST)
    assert_equal([['Madam,'], ["I'm"], ['Adam.']], result[bolt])
示例#7
0
def test():
    # To run this:
    # pip install nose
    # nosetests wordcount.py
    from nose.tools import assert_equal
    
    bolt = WordCountBolt()
    
    from petrel import mock
    from randomsentence import RandomSentenceSpout
    mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(), [
        ['word'],
        ['other'],
        ['word'],
    ])
    
    result = mock.run_simple_topology(None, [mock_spout, bolt], result_type=mock.LIST)
    assert_equal(2, bolt._count['word'])
    assert_equal(1, bolt._count['other'])
    assert_equal([['word', 1], ['other', 1], ['word', 2]], result[bolt])
示例#8
0
def test():
    # To run this:
    # pip install nose
    # nosetests wordcount.py
    from nose.tools import assert_equal

    bolt = WordCountBolt()

    from petrel import mock
    from randomsentence import RandomSentenceSpout
    mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(), [
        ['word'],
        ['other'],
        ['word'],
    ])

    result = mock.run_simple_topology(None, [mock_spout, bolt],
                                      result_type=mock.LIST)
    assert_equal(2, bolt._count['word'])
    assert_equal(1, bolt._count['other'])
    assert_equal([['word', 1], ['other', 1], ['word', 2]], result[bolt])