Skip to content

Commit

Permalink
test(test_data_preprocessor.py): mock pysoark.sql.functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Garett601 committed Oct 26, 2024
1 parent 6a8146a commit f25a887
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/preprocessing/test_data_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def test_save_to_catalog(data_processor, mock_spark_session, mocker):
data_processor.preprocess_data()
train_set, test_set = data_processor.split_data(test_size=0.2)

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

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

0 comments on commit f25a887

Please sign in to comment.