From 90b548da9abd83831595c6c0b97e4df4f2bec9ac Mon Sep 17 00:00:00 2001 From: vagrant Date: Thu, 18 Apr 2013 23:23:58 +0000 Subject: [PATCH] added fixture for sample data --- tests/conftest.py | 6 ++++++ tests/pulse_consumer/test_pulse_consumer.py | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index db568ee97..add0a8111 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -92,3 +92,9 @@ def increment_cache_key_prefix(): key_prefix_counter = 0 cache.set(prefix_counter_cache_key, key_prefix_counter) cache.key_prefix = "t{0}".format(key_prefix_counter) + +@pytest.fixture(scope='module') +def sample_data(): + """Returns a SampleData() object""" + from sampledata import SampleData + return SampleData() diff --git a/tests/pulse_consumer/test_pulse_consumer.py b/tests/pulse_consumer/test_pulse_consumer.py index 273b8d5df..401dbe837 100644 --- a/tests/pulse_consumer/test_pulse_consumer.py +++ b/tests/pulse_consumer/test_pulse_consumer.py @@ -1,9 +1,13 @@ -from treeherder.pulse_consumer.consumer import PulseDataAdapter, TreeherderDataAdapter -from ..sampledata import SampleData +import pytest -def test_process_data(): +from treeherder.pulse_consumer.consumer import PulseDataAdapter - sd = SampleData() + +def test_process_data(sample_data): + """ + Test the ability of PulseDataAdapter.process_data() to process the + raw data available in sample_data without missing any attributes. + """ pda = PulseDataAdapter( durable=False, @@ -14,7 +18,7 @@ def test_process_data(): msg = Message() - for data in sd.raw_pulse_data: + for data in sample_data.raw_pulse_data: data = pda.process_data(data, msg) @@ -25,7 +29,8 @@ def test_process_data(): assert set() == missing_attributes class Message(object): - + """Class that mimics the message object interface from + mozilla pulse""" def __init__(self): pass