def test():
    from nose.tools import assert_true
    from petrel import mock

    spout = RandomSentenceSpout()

    result = mock.run_simple_topology(None, [spout])
    assert_true(isinstance(result[spout][0], str))
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():
    # To run this:
    # pip install nose
    # nosetests wordcount.py
    from nose.tools import assert_true
    from petrel import mock
    spout = RandomSentenceSpout()
    result = mock.run_simple_topology([spout])
    assert_true(isinstance(result[spout][0].sentence, str))
예제 #4
0
def test():
    # To run this:
    # pip install nose
    # nosetests wordcount.py
    from nose.tools import assert_true
    from petrel import mock
    spout = RandomSentenceSpout()
    result = mock.run_simple_topology([spout])
    assert_true(isinstance(result[spout][0].sentence, str))
예제 #5
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])
예제 #6
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])
예제 #7
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])
예제 #8
0
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])
예제 #9
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])
예제 #10
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])
예제 #11
0
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])
예제 #12
0
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")
예제 #13
0
파일: wordcount.py 프로젝트: bonya/Petrel
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]]
예제 #14
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])
예제 #15
0
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]]
예제 #16
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([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])