Skip to content

Commit 094ce2f

Browse files
committed
fixed tests
1 parent d880ee4 commit 094ce2f

File tree

21 files changed

+68
-72
lines changed

21 files changed

+68
-72
lines changed

dlt/common/configuration/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __init__(self, field_name: str, field_value: Any, hint: type) -> None:
147147
self.field_value = field_value
148148
self.hint = hint
149149
super().__init__(
150-
f"Configured value for field {field_name} cannot be coerced into type {str(hint)}"
150+
f"Configured value for field `{field_name}` cannot be coerced into type `{str(hint)}`"
151151
)
152152

153153

dlt/common/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __init__(
141141
super().__init__(msg)
142142

143143
def __str__(self) -> str:
144-
return f"In path {self.path}: " + self.msg
144+
return f"Path `{self.path}`: " + self.msg
145145

146146

147147
class ArgumentsOverloadException(DltException):

dlt/common/validation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def validate_dict(
6868
# check missing props
6969
missing = set(required_props.keys()).difference(props.keys())
7070
if len(missing):
71-
raise DictValidationException(f"Missing required fields: `{missing}`", path)
71+
raise DictValidationException(f"missing required fields `{missing}`", path)
7272
# check unknown props
7373
unexpected = set(props.keys()).difference(allowed_props.keys())
7474
if len(unexpected):
75-
raise DictValidationException(f"Received unexpected fields: `{unexpected}`", path)
75+
raise DictValidationException(f"received unexpected fields `{unexpected}`", path)
7676

7777
def verify_prop(pk: str, pv: Any, t: Any) -> None:
7878
# covers none in optional and union types
@@ -99,7 +99,7 @@ def verify_prop(pk: str, pv: Any, t: Any) -> None:
9999
if len(failed_validations) == len(union_types):
100100
type_names = [get_type_name(ut) for ut in union_types]
101101
msg = (
102-
f"field '{pk}' expects the following types: {', '.join(type_names)}."
102+
f"field '{pk}' expects the following types: {type_names}."
103103
f" Provided value {pv} with type '{type(pv).__name__}' is invalid with the"
104104
" following errors:\n"
105105
)
@@ -121,12 +121,12 @@ def verify_prop(pk: str, pv: Any, t: Any) -> None:
121121
a_l = get_literal_args(t)
122122
if pv not in a_l:
123123
raise DictValidationException(
124-
f"field '{pk}' with value `{pv}` is not one of: {a_l}", path, t, pk, pv
124+
f"field `{pk}={pv}` is not one of: {a_l}", path, t, pk, pv
125125
)
126126
elif t in [int, bool, str, float]:
127127
if not isinstance(pv, t):
128128
raise DictValidationException(
129-
f"field '{pk}' with value `{pv}` has invalid type '{type(pv).__name__}' while"
129+
f"field `{pk}={pv}` has invalid type '{type(pv).__name__}' while"
130130
f" '{t.__name__}' is expected",
131131
path,
132132
t,

dlt/extract/incremental/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ def on_resolved(self) -> None:
285285
msg = (
286286
f"Incremental `initial_value={self.initial_value}` is greater than"
287287
f" `end_value={self.end_value}` as determined by the custom `last_value_func`."
288-
f" The result of '{self.last_value_func.__name__}(`[end_value,"
289-
" initial_value]`)' must equal `end_value`"
288+
f" The result of `{self.last_value_func.__name__}([end_value,"
289+
" initial_value])` must equal `end_value`"
290290
)
291291
raise ConfigurationValueError(msg)
292292

dlt/sources/rest_api/config_setup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def setup_incremental_object(
234234
if param_config.get("end_value") or param_config.get("end_param"):
235235
raise ValueError(
236236
"Only `start_param` and `initial_value` are allowed in the configuration of"
237-
f" param: {param_name} "
237+
f" param: `{param_name}`. "
238238
"To set `end_value` too use the incremental configuration at the resource"
239239
" level. "
240240
"See https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api/basic#incremental-loading"
@@ -499,8 +499,8 @@ def _bind_path_params(resource: EndpointResource) -> None:
499499
if len(resolve_params) > 0:
500500
raise ValueError(
501501
f"Resource `{resource['name']}` defines resolve params `{resolve_params}` that are not"
502-
f" bound in path `{path}`. To reference parent resource in query params use"
503-
" resources.<parent_resource>.<field> syntax."
502+
f" bound in path `{path}`. To reference parent resource in query params use syntax"
503+
" 'resources.<parent_resource>.<field>'"
504504
)
505505

506506
resource["endpoint"]["path"] = "".join(new_path_segments)
@@ -796,9 +796,9 @@ def collect_resolved_values(
796796
field_path = resolved_param.resolve_config["field"]
797797
raise ValueError(
798798
f"Resource expects a field `{field_path}` to be present in the incoming data from"
799-
f" resource `{parent_resource_name}` in order to bind it to path param"
799+
f" resource `{parent_resource_name}` in order to bind it to path param:"
800800
f" `{resolved_param.param_name}`. Available parent fields are:"
801-
f" [{', '.join(item.keys())}]"
801+
f" {list(item.keys())}"
802802
)
803803

804804
params_values[resolved_param.param_name] = field_values[0]
@@ -893,7 +893,7 @@ def build_parent_record(
893893
raise ValueError(
894894
f"Resource expects a field `{parent_key}` to be present in the incoming data "
895895
f"from resource `{parent_resource_name}` in order to include it in child records"
896-
f" under `{child_key}`. Available parent fields are: [{', '.join(item.keys())}]"
896+
f" under `{child_key}`. Available parent fields are: {list(item.keys())}"
897897
)
898898
parent_record[child_key] = item[parent_key]
899899
return parent_record
@@ -976,7 +976,7 @@ def _raise_if_any_not_in(expressions: Set[str], available_contexts: Set[str], me
976976
if not any(expression.startswith(prefix + ".") for prefix in available_contexts):
977977
raise ValueError(
978978
f"Expression `{expression}` defined in `{message}` is not valid. Valid expressions"
979-
f" must start with one of: [{', '.join(available_contexts)}]. If you need to use"
979+
f" must start with one of: `{available_contexts}`. If you need to use"
980980
" literal curly braces in your expression, escape them by doubling them: {{ and"
981981
" }}"
982982
)

dlt/sources/sql_database/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(
8888
self.cursor_column = table.c[column_name]
8989
except KeyError as e:
9090
raise KeyError(
91-
f"Cursor column `{incremental.cursor_path} `does not exist in table"
91+
f"Cursor column `{incremental.cursor_path}` does not exist in table"
9292
f" `{table.name}`"
9393
) from e
9494
self.last_value = incremental.last_value

tests/destinations/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ def other_resource():
4040
def other_source():
4141
return [some_resource, other_resource]
4242

43-
with pytest.raises(ValueErrorWithKnownValues):
43+
with pytest.raises(ValueError):
4444
get_resource_for_adapter(other_source())

tests/extract/test_incremental.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,15 +2061,13 @@ def some_data(
20612061
with pytest.raises(ConfigurationValueError) as ex:
20622062
list(some_data(updated_at=dlt.sources.incremental(end_value=22)))
20632063

2064-
assert str(ex.value).startswith("Incremental 'end_value' was specified without 'initial_value'")
2064+
assert str(ex.value).startswith("Incremental `end_value` was specified without `initial_value`")
20652065

20662066
# max function and end_value lower than initial_value
20672067
with pytest.raises(ConfigurationValueError) as ex:
20682068
list(some_data(updated_at=dlt.sources.incremental(initial_value=42, end_value=22)))
20692069

2070-
assert str(ex.value).startswith(
2071-
"Incremental 'initial_value' (42) is higher than 'end_value` (22)"
2072-
)
2070+
assert str(ex.value).startswith("Incremental `initial_value=42` is higher than `end_value=22`")
20732071

20742072
# max function and end_value higher than initial_value
20752073
with pytest.raises(ConfigurationValueError) as ex:
@@ -2081,9 +2079,7 @@ def some_data(
20812079
)
20822080
)
20832081

2084-
assert str(ex.value).startswith(
2085-
"Incremental 'initial_value' (22) is lower than 'end_value` (42)."
2086-
)
2082+
assert str(ex.value).startswith("Incremental `initial_value=22` is lower than `end_value=42`.")
20872083

20882084
def custom_last_value(items):
20892085
return max(items)
@@ -2099,7 +2095,7 @@ def custom_last_value(items):
20992095
)
21002096

21012097
assert (
2102-
"The result of 'custom_last_value([end_value, initial_value])' must equal 'end_value'"
2098+
"The result of `custom_last_value([end_value, initial_value])` must equal `end_value`"
21032099
in str(ex.value)
21042100
)
21052101

tests/helpers/dbt_tests/test_runner_dbt_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_dbt_run_exception_pickle() -> None:
134134
assert obj.command == "test"
135135
assert obj.run_results == "A"
136136
assert obj.dbt_results == "B"
137-
assert str(obj) == "DBT command test could not be executed"
137+
assert str(obj) == "DBT command `test` could not be executed"
138138

139139

140140
def test_runner_setup(client: PostgresClient, test_storage: FileStorage) -> None:

tests/load/pipeline/test_model_item_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
)
7575
def test_model_builder_with_non_select_query(unsupported_model_query: str) -> None:
7676
with pytest.raises(
77-
ValueError, match="Only SELECT statements are allowed to create a SqlModel."
77+
ValueError, match="Only SELECT statements are allowed to create a `SqlModel`."
7878
):
7979
SqlModel.from_query_string(query=unsupported_model_query)
8080

0 commit comments

Comments
 (0)