Skip to content

Commit

Permalink
add functions to write_catalog (singer-io#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
KAllan357 authored and Judah Rand committed Oct 27, 2020
1 parent c49d456 commit b75e7b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit b75e7b0

Please sign in to comment.