コード例 #1
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])
コード例 #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])
コード例 #3
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])
コード例 #4
0
ファイル: wordcount.py プロジェクト: xenron/sandbox-da-python
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
ファイル: splitsentence.py プロジェクト: kbourgoin/Petrel
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
ファイル: wordcount.py プロジェクト: AirSage/Petrel
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
ファイル: wordcount.py プロジェクト: vedantja/Petrel
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])
コード例 #9
0
def create(builder):
    builder.setSpout("spout", RandomSentenceSpout(), 1)
    builder.setBolt(
        "split", SplitSentenceBolt(), 1).shuffleGrouping("spout")
    builder.setBolt(
        "count", WordCountBolt(), 1).fieldsGrouping("split", ["word"])