Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to write_catalog #101

Merged
merged 1 commit into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions singer/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
LOGGER = get_logger()


def write_catalog(catalog):
# If the catalog has no streams, log a warning
if not catalog.streams:
LOGGER.warning("Catalog being written with no streams.")

json.dump(catalog.to_dict(), sys.stdout, indent=2)

# pylint: disable=too-many-instance-attributes
class CatalogEntry():

Expand Down
11 changes: 10 additions & 1 deletion tests/test_catalog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import unittest

from singer.schema import Schema
from singer.catalog import Catalog, CatalogEntry
from singer.catalog import Catalog, CatalogEntry, write_catalog

class TestWriteCatalog(unittest.TestCase):
def test_write_empty_catalog(self):
catalog = Catalog([])
write_catalog(catalog)

def test_write_catalog_with_streams(self):
catalog = Catalog([CatalogEntry(tap_stream_id='a',schema=Schema(),metadata=[])])
write_catalog(catalog)

class TestGetSelectedStreams(unittest.TestCase):
def test_one_selected_stream(self):
Expand Down