Skip to content

Commit 79eb192

Browse files
committed
passing tests
1 parent cdb1648 commit 79eb192

File tree

10 files changed

+28
-25
lines changed

10 files changed

+28
-25
lines changed

dlt/common/validation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def verify_prop(pk: str, pv: Any, t: Any) -> None:
108108
failed_validations, key=lambda ex: ex.path.count("/"), reverse=True
109109
)
110110
for failed in failed_validations:
111-
msg += f"For {get_type_name(failed.expected_type)}: " + str(failed) + "\n"
111+
msg += f"For `{get_type_name(failed.expected_type)}`: " + str(failed) + "\n"
112112
raise DictValidationException(
113113
msg,
114114
path,
@@ -204,8 +204,8 @@ def verify_prop(pk: str, pv: Any, t: Any) -> None:
204204
if inspect.isclass(t):
205205
if not isinstance(pv, t):
206206
raise DictValidationException(
207-
f"field '{pk}' expects class '{type_name}' but got instance of"
208-
f" '{pv_type_name}'",
207+
f"field `{pk}` expects class `{type_name}` but got instance of"
208+
f" `{pv_type_name}`",
209209
path,
210210
t,
211211
pk,
@@ -214,7 +214,7 @@ def verify_prop(pk: str, pv: Any, t: Any) -> None:
214214
# dropped, just __name__ can be used
215215
type_name = get_type_name(t)
216216
raise DictValidationException(
217-
f"field '{pk}' has expected type '{type_name}' which lacks validator",
217+
f"field `{pk}` has expected type `{type_name}` which lacks validator",
218218
path,
219219
t,
220220
pk,

dlt/destinations/impl/bigquery/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def create_load_job(
225225
if table["write_disposition"] != "append":
226226
raise DestinationTerminalException(
227227
"BigQuery streaming insert can only be used with"
228-
" `write_disposition='append'`.Resource received"
228+
" `write_disposition='append'`. Resource received"
229229
f" `write_disposition={table['write_disposition']}`"
230230
)
231231
if file_path.endswith(".jsonl"):

tests/load/bigquery/test_bigquery_streaming_insert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def test_resource():
5050
# pick the failed job
5151
assert isinstance(pip_ex.value.__cause__, LoadClientJobFailed)
5252
assert (
53-
"""BigQuery streaming insert can only be used with `append`"""
54-
""" write_disposition, while the given resource has `merge`."""
55-
) in pip_ex.value.__cause__.failed_message
53+
"BigQuery streaming insert can only be used with `write_disposition='append'`"
54+
"Resource received `write_disposition=merge`"
55+
in pip_ex.value.__cause__.failed_message
56+
)
5657

5758

5859
def test_bigquery_streaming_nested_data():

tests/load/bigquery/test_bigquery_table_builder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,7 @@ def some_data() -> Iterator[Dict[str, Any]]:
568568

569569
with pytest.raises(
570570
ValueError,
571-
match=(
572-
"^`partition` must be a single column name as a string or a PartitionTransformation.$"
573-
),
571+
match="`partition` must be a single column name as a `str` or a `PartitionTransformation`.",
574572
):
575573
bigquery_adapter(some_data, partition=["col1", "col2"])
576574

tests/load/databricks/test_databricks_configuration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_databricks_auth_invalid() -> None:
110110

111111
def test_databricks_missing_config_catalog() -> None:
112112
with pytest.raises(
113-
ConfigurationValueError, match="Configuration error: Missing required parameter 'catalog'*"
113+
ConfigurationValueError, match="Configuration error: Missing required parameter `catalog`"
114114
):
115115
os.environ["DESTINATION__DATABRICKS__CREDENTIALS__CATALOG"] = ""
116116
bricks = databricks()
@@ -120,7 +120,7 @@ def test_databricks_missing_config_catalog() -> None:
120120
def test_databricks_missing_config_http_path() -> None:
121121
with pytest.raises(
122122
ConfigurationValueError,
123-
match="Configuration error: Missing required parameter 'http_path'*",
123+
match="Configuration error: Missing required parameter `http_path`",
124124
):
125125
os.environ["DESTINATION__DATABRICKS__CREDENTIALS__HTTP_PATH"] = ""
126126
bricks = databricks()
@@ -130,7 +130,7 @@ def test_databricks_missing_config_http_path() -> None:
130130
def test_databricks_missing_config_server_hostname() -> None:
131131
with pytest.raises(
132132
ConfigurationValueError,
133-
match="Configuration error: Missing required parameter 'server_hostname'*",
133+
match="Configuration error: Missing required parameter `server_hostname`",
134134
):
135135
os.environ["DESTINATION__DATABRICKS__CREDENTIALS__SERVER_HOSTNAME"] = ""
136136
bricks = databricks()

tests/sources/rest_api/configurations/source_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
},
8585
),
8686
ConfigTest(
87-
expected_message="field `paginator='invalid_paginator'` is not one of:",
87+
expected_message="field `paginator` expects the following types: ",
8888
exception=DictValidationException,
8989
config={
9090
"client": {

tests/sources/rest_api/configurations/test_auth_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,5 @@ def test_validation_masks_auth_secrets() -> None:
314314
rest_api_source(incorrect_config)
315315
assert (
316316
re.search("sensitive-secret", str(e.value)) is None
317-
), "unexpectedly printed 'sensitive-secret'"
318-
assert e.match(re.escape("'{'type': 'bearer', 'location': 'header', 'token': 's*****t'}'"))
317+
), "unexpectedly printed `sensitive-secret`"
318+
assert e.match(re.escape("`{'type': 'bearer', 'location': 'header', 'token': 's*****t'}`"))

tests/sources/rest_api/configurations/test_incremental_config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_invalid_incremental_type_is_not_accepted() -> None:
5353
with pytest.raises(ValueErrorWithKnownValues) as e:
5454
_validate_param_type(request_params)
5555

56-
assert e.match("Received invalid value `since['type']=no_incremental`.")
56+
assert e.match(r"Received invalid value `since\['type'\]=no_incremental`.")
5757

5858

5959
def test_one_resource_cannot_have_many_incrementals() -> None:
@@ -185,15 +185,16 @@ def test_does_not_construct_incremental_from_request_param_with_unsupported_incr
185185
setup_incremental_object(param_config_2)
186186

187187
assert e.match(
188-
"Only start_param and initial_value are allowed in the configuration of param: since_2."
188+
"Only `start_param` and `initial_value` are allowed in the configuration of param:"
189+
" `since_2`."
189190
)
190191

191192
param_config_3 = {"since_3": incremental_with_init_and_end}
192193

193194
with pytest.raises(ValueError) as e:
194195
setup_incremental_object(param_config_3)
195196

196-
assert e.match("Only initial_value is allowed in the configuration of param: since_3.")
197+
assert e.match("Only `initial_value` is allowed in the configuration of param: `since_3`.")
197198

198199

199200
def test_constructs_incremental_from_endpoint_config_incremental(

tests/sources/rest_api/configurations/test_paginator_config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ def test_allow_deprecated_json_response_paginator_2(mock_api_server) -> None:
148148
def test_error_message_invalid_paginator() -> None:
149149
with pytest.raises(ValueError) as e:
150150
create_paginator("non_existing_method") # type: ignore
151-
assert (
152-
str(e.value)
153-
== "Received invalid value `paginator_name=non_existing_method`. Valid values are:"
151+
assert e.match(
152+
r"Received invalid value `paginator_name=non_existing_method`\. Valid values are:"
154153
)

tests/sources/rest_api/configurations/test_response_actions_config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ class C:
4545

4646
with pytest.raises(TypeErrorWithKnownTypes) as e_1:
4747
_handle_response_action(response, {"status_code": 200, "action": C()}) # type: ignore[typeddict-item]
48-
assert e_1.match("Received invalid value `action['action']=*` of type `C`. Valid types are:")
48+
assert e_1.match(
49+
r"Received invalid value `action\['action'\]=.*` of type `C`\. Valid types are:"
50+
)
4951

5052
with pytest.raises(TypeErrorWithKnownTypes) as e_2:
5153
_handle_response_action(response, {"status_code": 200, "action": 123}) # type: ignore[typeddict-item]
52-
assert e_2.match("Received invalid value `action['action']=*` of type `C`. Valid types are:")
54+
assert e_2.match(
55+
r"Received invalid value `action\['action'\]=.*` of type `int`\. Valid types are:"
56+
)
5357

5458
assert ("ignore", None) == _handle_response_action(
5559
response, {"status_code": 200, "action": "ignore"}

0 commit comments

Comments
 (0)