Skip to content

Commit

Permalink
Switch to using Nones instead of empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams authored and albertkol committed Sep 20, 2024
1 parent cfd8f67 commit 79949c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
8 changes: 4 additions & 4 deletions data_store/messaging/tf_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _wrong_type_failure_message(self, validation_failure: WrongTypeFailure) -> M
[validation_failure.column] if isinstance(validation_failure.column, str) else validation_failure.column
)

cell_index = tuple(
cell_index: tuple[str, ...] | None = tuple(
self._construct_cell_index(
table=validation_failure.table,
column=column,
Expand All @@ -318,7 +318,7 @@ def _wrong_type_failure_message(self, validation_failure: WrongTypeFailure) -> M
cell_index = (
(self._get_cell_indexes_for_outcomes(validation_failure.failed_row),)
if validation_failure.failed_row is not None
else ("",)
else None
)
if validation_failure.expected_type == datetime:
message = self.msgs.WRONG_TYPE_DATE.format(wrong_type=actual_type)
Expand Down Expand Up @@ -388,7 +388,7 @@ def _non_nullable_constraint_failure_message(self, validation_failure: NonNullab
[validation_failure.column] if isinstance(validation_failure.column, str) else validation_failure.column
)

cell_index = tuple(
cell_index: tuple[str, ...] | None = tuple(
self._construct_cell_index(
table=validation_failure.table,
column=column,
Expand All @@ -412,7 +412,7 @@ def _non_nullable_constraint_failure_message(self, validation_failure: NonNullab
cell_index = (
(self._get_cell_indexes_for_outcomes(validation_failure.failed_row),)
if validation_failure.failed_row is not None
else ("",)
else None
)
elif sheet == "Funding Profiles":
message = self.msgs.BLANK_ZERO
Expand Down
28 changes: 0 additions & 28 deletions tests/data_store_tests/messaging_tests/test_tf_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,34 +559,6 @@ def test_failures_to_message_with_outcomes_column_amount():
)


def test_failures_to_message_with_outcomes_column_without_failed_row():
test_messger = TFMessenger()

failure1 = WrongTypeFailure(
table="Outcome_Data",
column="Amount",
expected_type=float,
actual_type=str,
row_index=23,
failed_row=None,
)

# message needs to have an index, which does not exist when failed_row is None
with pytest.raises(ValueError):
test_messger.to_message(failure1)

failure2 = NonNullableConstraintFailure(
table="Outcome_Data",
column="Amount",
row_index=60,
failed_row=None,
)

# message needs to have an index, which does not exist when failed_row is None
with pytest.raises(ValueError):
test_messger.to_message(failure2)


def test_failures_to_message_with_duplicated_errors():
test_messger = TFMessenger()
failed_row1 = pd.Series({"Start_Date": pd.to_datetime("2023-05-01 12:00:00")}, name=60)
Expand Down

0 comments on commit 79949c0

Please sign in to comment.