basic emitter tests

This commit is contained in:
James Turk 2010-02-21 14:20:48 -05:00
parent 13d8d1365b
commit a6574ecba7
2 changed files with 27 additions and 0 deletions

View File

@ -1,9 +1,11 @@
import unittest
from saucebrush.tests.filters import FilterTestCase
from saucebrush.tests.sources import SourceTestCase
from saucebrush.tests.emitters import EmitterTestCase
filter_suite = unittest.TestLoader().loadTestsFromTestCase(FilterTestCase)
source_suite = unittest.TestLoader().loadTestsFromTestCase(SourceTestCase)
emitter_suite = unittest.TestLoader().loadTestsFromTestCase(EmitterTestCase)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,25 @@
import unittest
from cStringIO import StringIO
from saucebrush.emitters import DebugEmitter, CSVEmitter
class EmitterTestCase(unittest.TestCase):
def setUp(self):
self.output = StringIO()
def test_debug_emitter(self):
de = DebugEmitter(self.output)
data = de.attach([1,2,3])
for _ in data:
pass
self.assertEquals(self.output.getvalue(), '1\n2\n3\n')
def test_csv_emitter(self):
ce = CSVEmitter(self.output, ('x','y','z'))
data = ce.attach([{'x':1,'y':2,'z':3}, {'x':5, 'y':5, 'z':5}])
for _ in data:
pass
self.assertEquals(self.output.getvalue(), 'x,y,z\r\n1,2,3\r\n5,5,5\r\n')
if __name__ == '__main__':
unittest.main()