Skip to content

Commit

Permalink
New API WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Corsaro committed Feb 7, 2016
1 parent 3889659 commit 8a3f9a0
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 603 deletions.
43 changes: 0 additions & 43 deletions tests/test_elasticsearch.py

This file was deleted.

33 changes: 12 additions & 21 deletions tests/test_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os.path
import unittest2 as unittest
from io import BytesIO
from tubing import sinks, sources, pipe
from tubing import sinks, sources, pipes

SOURCE_DATA = [
dict(name="Bob", age=38),
Expand All @@ -18,28 +18,19 @@


class PipeTestCase(unittest.TestCase):

def testPipe(self):
buffer0 = sinks.BytesIOSink()
sink = sinks.JSONSerializerSink(buffer0, "\n", separators=(',', ':'))
for obj in SOURCE_DATA:
sink.write([obj])
sink.done()
source = sources.Objects(SOURCE_DATA)
sink = sinks.Objects()
source | pipes.JSONSerializer(separators=(',', ':')) | pipes.Joined(by=b"\n") | pipes.Gzip() | pipes.Gunzip() | pipes.Split(on=b"\n") | pipes.JSONParser() | sink

buffer0.seek(0)
buffer1 = sinks.BytesIOSink()
source = sources.JSONParserSource(sources.LineReaderSource(buffer0))
sink = sinks.JSONSerializerSink(sinks.ZlibSink(sinks.BufferedSink(buffer1)), delimiter="\n")
pipe.pipe(source, sink, amt=1)

buffer1.seek(0)
source = sources.JSONParserSource(sources.LineReaderSource(sources.ZlibSource(buffer1)))
self.assertEqual(source.read(1), [SOURCE_DATA[0]])
self.assertEqual(source.read(1), [SOURCE_DATA[1]])
self.assertEqual(source.read(1), [SOURCE_DATA[2]])
self.assertEqual(source.read(1), [SOURCE_DATA[3]])
self.assertEqual(source.read(), [])

def testFailingSink(self):
self.assertEqual(sink[0], SOURCE_DATA[0])
self.assertEqual(sink[1], SOURCE_DATA[1])
self.assertEqual(sink[2], SOURCE_DATA[2])
self.assertEqual(sink[3], SOURCE_DATA[3])


def xtestFailingSink(self):
class FailSink(object):
def __init__(self):
self._done = False
Expand Down
66 changes: 0 additions & 66 deletions tests/test_sinks.py

This file was deleted.

47 changes: 0 additions & 47 deletions tests/test_sources.py

This file was deleted.

Empty file removed tubing/ext/__init__.py
Empty file.
99 changes: 0 additions & 99 deletions tubing/ext/elasticsearch.py

This file was deleted.

83 changes: 0 additions & 83 deletions tubing/ext/s3.py

This file was deleted.

Loading

0 comments on commit 8a3f9a0

Please sign in to comment.