Here are the examples of the python api petrel.mock.MockSpout taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Example 1
Project: Petrel Source File: splitsentence.py
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])
0
Example 2
Project: Petrel Source File: wordcount.py
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])