basic emitter tests
This commit is contained in:
parent
13d8d1365b
commit
a6574ecba7
@ -1,9 +1,11 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from saucebrush.tests.filters import FilterTestCase
|
from saucebrush.tests.filters import FilterTestCase
|
||||||
from saucebrush.tests.sources import SourceTestCase
|
from saucebrush.tests.sources import SourceTestCase
|
||||||
|
from saucebrush.tests.emitters import EmitterTestCase
|
||||||
|
|
||||||
filter_suite = unittest.TestLoader().loadTestsFromTestCase(FilterTestCase)
|
filter_suite = unittest.TestLoader().loadTestsFromTestCase(FilterTestCase)
|
||||||
source_suite = unittest.TestLoader().loadTestsFromTestCase(SourceTestCase)
|
source_suite = unittest.TestLoader().loadTestsFromTestCase(SourceTestCase)
|
||||||
|
emitter_suite = unittest.TestLoader().loadTestsFromTestCase(EmitterTestCase)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
25
saucebrush/tests/emitters.py
Normal file
25
saucebrush/tests/emitters.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user