Skip to content

Commit

Permalink
More rich assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Mar 20, 2024
1 parent c899533 commit c8cda77
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def validate(self) -> None:
assert result.rowcount == 4
row = result.first()
if self.target.config.get("add_record_metadata", True):
assert len(row) == 8
assert len(row) == 8, f"Row has unexpected length {len(row)}"
else:
assert len(row) == 2
assert len(row) == 2, f"Row has unexpected length {len(row)}"

assert row[1] == '[\n "apple",\n "orange",\n "pear"\n]'
table_schema = connector.get_table(table)
Expand Down Expand Up @@ -85,6 +85,7 @@ def validate(self) -> None:
"_sdc_batched_at": sct.TIMESTAMP_NTZ,
"_sdc_received_at": sct.TIMESTAMP_NTZ,
"_sdc_deleted_at": sct.TIMESTAMP_NTZ,
"_sdc_sync_started_at": sct.NUMBER,
"_sdc_table_version": sct.NUMBER,
"_sdc_sequence": sct.NUMBER,
}
Expand Down Expand Up @@ -237,9 +238,9 @@ def validate(self) -> None:
assert result.rowcount == 2
row = result.first()
if self.target.config.get("add_record_metadata", True):
assert len(row) == 7
assert len(row) == 7, f"Row has unexpected length {len(row)}"
else:
assert len(row) == 1
assert len(row) == 1, f"Row has unexpected length {len(row)}"

table_schema = connector.get_table(table)
expected_types = {
Expand Down Expand Up @@ -271,9 +272,9 @@ def validate(self) -> None:
row = result.first()

if self.target.config.get("add_record_metadata", True):
assert len(row) == 13
assert len(row) == 13, f"Row has unexpected length {len(row)}"
else:
assert len(row) == 7
assert len(row) == 7, f"Row has unexpected length {len(row)}"

table_schema = connector.get_table(table)
expected_types = {
Expand Down Expand Up @@ -317,7 +318,7 @@ def validate(self) -> None:
)
assert result.rowcount == 2
row = result.first()
assert len(row) == 11
assert len(row) == 11, f"Row has unexpected length {len(row)}"


class SnowflakeTargetReservedWordsNoKeyProps(TargetFileTestTemplate):
Expand All @@ -339,7 +340,7 @@ def validate(self) -> None:
)
assert result.rowcount == 1
row = result.first()
assert len(row) == 10
assert len(row) == 10, f"Row has unexpected length {len(row)}"


class SnowflakeTargetColonsInColName(TargetFileTestTemplate):
Expand All @@ -358,7 +359,7 @@ def validate(self) -> None:
)
assert result.rowcount == 1
row = result.first()
assert len(row) == 11
assert len(row) == 12, f"Row has unexpected length {len(row)}"
table_schema = connector.get_table(table)
assert {column.name for column in table_schema.columns} == {
"FOO::BAR",
Expand All @@ -370,6 +371,7 @@ def validate(self) -> None:
"_sdc_batched_at",
"_sdc_received_at",
"_sdc_deleted_at",
"_sdc_sync_started_at",
"_sdc_table_version",
"_sdc_sequence",
}
Expand Down Expand Up @@ -414,7 +416,7 @@ def validate(self) -> None:
)
assert result.rowcount == 1
row = result.first()
assert len(row) == 12
assert len(row) == 12, f"Row has unexpected length {len(row)}"


class SnowflakeTargetExistingTableAlter(SnowflakeTargetExistingTable):
Expand Down Expand Up @@ -466,6 +468,7 @@ def validate(self) -> None:
"_sdc_batched_at": sct.TIMESTAMP_NTZ,
"_sdc_received_at": sct.TIMESTAMP_NTZ,
"_sdc_deleted_at": sct.TIMESTAMP_NTZ,
"_sdc_sync_started_at": sct.NUMBER,
"_sdc_table_version": sct.NUMBER,
"_sdc_sequence": sct.NUMBER,
}
Expand Down

0 comments on commit c8cda77

Please sign in to comment.