Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vighnesh-wednesday committed Oct 21, 2024
1 parent 38493cb commit dff52e3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/test_spark_wrapper_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ def test_value_counts_invalid_column(self):
with self.assertRaises(U.AnalysisException) as context:
value_counts(self.df, "nonexistent_column")

expected_error_message = re.compile("Column '.+' does not exist")
expected_error_message_1 = re.compile("Column '.+' does not exist")
expected_error_message_2 = re.compile("cannot resolve '.+' given input columns:")
actual_error_message = str(context.exception)

self.assertTrue(expected_error_message.search(actual_error_message))
self.assertTrue(expected_error_message_1.search(actual_error_message)
or expected_error_message_2.search(actual_error_message))

def test_create_frame_invalid_path(self):
with self.assertRaises(U.AnalysisException) as context:
Expand All @@ -48,19 +50,23 @@ def test_make_window_invalid_window_spec(self):
window_spec = make_window("invalid_column", "date", -20, -1)
self.df.withColumn("literal_1", F.lit(1).over(window_spec))

expected_error_message = re.compile("Column '.+' does not exist")
expected_error_message_1 = re.compile("Column '.+' does not exist")
expected_error_message_2 = re.compile("cannot resolve '.+' given input columns:")
actual_error_message = str(context.exception)

self.assertTrue(expected_error_message.search(actual_error_message))
self.assertTrue(expected_error_message_1.search(actual_error_message)
or expected_error_message_2.search(actual_error_message))

def test_make_window_invalid_range(self):
with self.assertRaises(U.AnalysisException) as context:
window_spec = make_window("market", "date", 5, 2)
self.df.withColumn("literal_1", F.lit(1).over(window_spec))

expected_error_message = "The lower bound of a window frame must be less than or equal to the upper bound"
expected_error_message_1 = "The lower bound of a window frame must be less than or equal to the upper bound"
exoected_error_message_2 = re.compile("The data type of the lower bound '.+' does not match the expected data type '.+'")
actual_error_message = str(context.exception)
self.assertTrue(expected_error_message in actual_error_message)
self.assertTrue(expected_error_message_1 in actual_error_message
or exoected_error_message_2.search(actual_error_message))

def test_rename_column_invalid_column(self):
with self.assertRaises(ValueError) as context:
Expand Down

0 comments on commit dff52e3

Please sign in to comment.