Skip to content

Commit f25a887

Browse files
committed
test(test_data_preprocessor.py): mock pysoark.sql.functions
1 parent 6a8146a commit f25a887

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/preprocessing/test_data_preprocessor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def test_save_to_catalog(data_processor, mock_spark_session, mocker):
142142
data_processor.preprocess_data()
143143
train_set, test_set = data_processor.split_data(test_size=0.2)
144144

145-
mocker.patch('pyspark.sql.functions.current_timestamp', return_value=F.lit("2024-10-24T13:29:49.272+00:00"))
145+
mock_lit = mocker.Mock()
146+
mock_lit.return_value = "2024-10-24T13:29:49.272+00:00"
147+
mocker.patch('pyspark.sql.functions.lit', mock_lit)
148+
mocker.patch('pyspark.sql.functions.current_timestamp', return_value=mock_lit("2024-10-24T13:29:49.272+00:00"))
146149
data_processor.save_to_catalog(train_set, test_set, mock_spark_session)
147150

148151
# Assert that createDataFrame was called twice (once for train_set, once for test_set)

0 commit comments

Comments
 (0)