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])
def test(): from nose.tools import assert_equal from petrel import mock bolt = SplitSentenceBolt() from RandomSentenceSpout import RandomSentenceSpout mock_spout = mock.MockSpout( RandomSentenceSpout.declareOutputFields(), [["Test this Bolt"]], ) result = mock.run_simple_topology(None, [mock_spout, bolt], result_type=mock.LIST) assert_equal([["Test"], ["this"], ["Bolt"]], result[bolt])
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])
def testWordCountBolt(): from nose.tools import assert_equal bolt = WordCountBolt() from petrel import mock from RandomSentenceSpout 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])
def testWordCountBolt(): from nose.tools import assert_equal bolt = ChicagoCrimeSplitterBolt() from petrel import mock from ChicagoCrimeSpout import ChicagoCrimeSpout mock_spout = mock.MockSpout(ChicagoCrimeSpout.declareOutputFields(), [[ "2147528,HH392600,05\/23\/2002 11:30:00 PM,011XX N LAWNDALE AVE,0925,MOTOR VEHICLE THEFT,\"ATT: TRUCK, BUS, MOTOR HOME\",STREET,false,false,1112,011,27,23,07,1151504,1907267,2002,04\/15\/2016 08:55:02 AM,41.901422057,-87.718953928,\"(41.901422057, -87.718953928)\"" ]]) result = mock.run_simple_topology(None, [mock_spout, bolt], result_type=mock.LIST) assert_equal(" MOTOR HOME")
def test_topology(): """Run topology test with 'py.test wordcount.py'""" from petrel import mock mock_spout = mock.MockSpout(RandomSentenceSpout.declareOutputFields(), [["Madam, I'm Adam."]]) split_sentence = SplitSentenceBolt() word_count = WordCountBolt() result = mock.run_simple_topology(None, [mock_spout, split_sentence, word_count], result_type=mock.LIST) split_sentence_result = result[split_sentence] word_count_result = result[word_count] assert len(split_sentence_result) == 3 assert len(word_count_result) == 3 assert split_sentence_result == [['Madam,'], ["I'm"], ['Adam.']] assert word_count_result == [['Madam,', 1], ["I'm", 1], ['Adam.', 1]]
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([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])