Skip to content

Commit

Permalink
Merge branch 'dev/guion-bluford' into feature/parse-csv-seeds-only
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Oct 8, 2018
2 parents 4b8d19c + 2f72c0e commit b523590
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
17 changes: 0 additions & 17 deletions dbt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,6 @@ def _is_hook_path(keypath):

return False

@staticmethod
def _is_port_path(keypath):
return len(keypath) == 2 and keypath[-1] == 'port'

@staticmethod
def _convert_port(value, keypath):

if len(keypath) != 4:
return value

if keypath[-1] == 'port' and keypath[1] == 'outputs':
try:
return int(value)
except ValueError:
pass # let the validator or connection handle this
return value

def _render_project_entry(self, value, keypath):
"""Render an entry, in case it's jinja. This is meant to be passed to
dbt.utils.deep_map.
Expand Down
3 changes: 1 addition & 2 deletions dbt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ def deep_map(func, value, keypath=(), memo=None, _notfound=object()):
ret = func(value, keypath)
else:
ok_types = (list, dict) + atomic_types
# TODO(jeb): real error
raise TypeError(
raise dbt.exceptions.DbtConfigError(
'in deep_map, expected one of {!r}, got {!r}'
.format(ok_types, type(value))
)
Expand Down
14 changes: 14 additions & 0 deletions test/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import dbt.exceptions
import dbt.utils


Expand Down Expand Up @@ -125,3 +126,16 @@ def test__keypath(self):
actual = dbt.utils.deep_map(self.special_keypath, expected)
self.assertEquals(actual, expected)

def test__noop(self):
actual = dbt.utils.deep_map(lambda x, _: x, self.input_value)
self.assertEquals(actual, self.input_value)

def test_trivial(self):
cases = [[], {}, 1, 'abc', None, True]
for case in cases:
result = dbt.utils.deep_map(lambda x, _: x, case)
self.assertEquals(result, case)

with self.assertRaises(dbt.exceptions.DbtConfigError):
dbt.utils.deep_map(lambda x, _: x, {'foo': object()})

0 comments on commit b523590

Please sign in to comment.