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

Allow empty lists in get_standard_metadata #106

Merged
merged 1 commit into from
Aug 28, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions singer/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def get_standard_metadata(schema=None, schema_name=None, key_properties=None,
valid_replication_keys=None, replication_method=None):
mdata = {}

if key_properties:
if key_properties is not None:
mdata = write(mdata, (), 'table-key-properties', key_properties)
if replication_method:
mdata = write(mdata, (), 'forced-replication-method', replication_method)
if valid_replication_keys:
if valid_replication_keys is not None:
mdata = write(mdata, (), 'valid-replication-keys', valid_replication_keys)
if schema:
mdata = write(mdata, (), 'inclusion', 'available')
Expand Down
8 changes: 8 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,11 @@ def test_standard_metadata(self):
for obj in expected_metadata:
if obj in test_value:
self.assertIn(obj, test_value)

def test_empty_key_properties_are_written(self):
mdata = get_standard_metadata(key_properties=[])
self.assertEqual(mdata, [{'breadcrumb': (), 'metadata': {'table-key-properties': []}}])

def test_empty_valid_replication_keys_are_written(self):
mdata = get_standard_metadata(valid_replication_keys=[])
self.assertEqual(mdata, [{'breadcrumb': (), 'metadata': {'valid-replication-keys': []}}])