Skip to content

Commit

Permalink
add missing tests and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Jan 13, 2024
1 parent f609fc8 commit 381ae3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dlt/common/data_types/type_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def coerce_value(to_type: TDataType, from_type: TDataType, value: Any) -> Any:
if from_type == "text":
try:
return json.loads(value)
except Exception as e:
except Exception:
pass

if to_type == "text":
Expand Down
2 changes: 1 addition & 1 deletion tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def assert_all_data_types_row(
if expect_filtered_null_columns:
for key, expected in expected_rows.items():
if expected is None:
assert db_mapping.get(key, None) == None
assert db_mapping.get(key, None) is None
db_mapping[key] = None

for key, expected in expected_rows.items():
Expand Down
10 changes: 10 additions & 0 deletions tests/common/schema/test_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,16 @@ def test_coerce_type_complex() -> None:
assert coerce_value("complex", "complex", v_list) == v_list
assert coerce_value("text", "complex", v_dict) == json.dumps(v_dict)
assert coerce_value("text", "complex", v_list) == json.dumps(v_list)
assert coerce_value("complex", "text", json.dumps(v_dict)) == v_dict
assert coerce_value("complex", "text", json.dumps(v_list)) == v_list

# all other coercions fail
with pytest.raises(ValueError):
coerce_value("binary", "complex", v_list)

with pytest.raises(ValueError):
coerce_value("complex", "text", "not a json string")


def test_coerce_type_complex_with_pua() -> None:
v_dict = {
Expand All @@ -395,6 +401,10 @@ def test_coerce_type_complex_with_pua() -> None:
}
assert coerce_value("complex", "complex", copy(v_dict)) == exp_v
assert coerce_value("text", "complex", copy(v_dict)) == json.dumps(exp_v)

# TODO: what to test for this case if at all?
# assert coerce_value("complex", "text", json.dumps(v_dict)) == exp_v

# also decode recursively
custom_pua_decode_nested(v_dict)
# restores datetime type
Expand Down
2 changes: 2 additions & 0 deletions tests/load/weaviate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def delete_classes(p, class_list):

def drop_active_pipeline_data() -> None:
def schema_has_classes(client):
if not hasattr(client, "db_client"):
return None
schema = client.db_client.schema.get()
return schema["classes"]

Expand Down

0 comments on commit 381ae3a

Please sign in to comment.