Skip to content

Commit 51694b7

Browse files
add unit test for filter_session_conf
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent d355480 commit 51694b7

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

tests/unit/test_sea_backend.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,70 @@ def test_utility_methods(self, sea_client):
633633
sea_client._extract_description_from_manifest(no_columns_manifest) is None
634634
)
635635

636+
def test_filter_session_configuration_string_values(self):
637+
"""Test that _filter_session_configuration converts all values to strings."""
638+
session_config = {
639+
"ANSI_MODE": True,
640+
"statement_timeout": 3600,
641+
"TIMEZONE": "UTC",
642+
"enable_photon": False,
643+
"MAX_FILE_PARTITION_BYTES": 128.5,
644+
"unsupported_param": "value",
645+
"ANOTHER_UNSUPPORTED": 42,
646+
}
647+
648+
result = _filter_session_configuration(session_config)
649+
650+
# Verify result is not None
651+
assert result is not None
652+
653+
# Verify all returned values are strings
654+
for key, value in result.items():
655+
assert isinstance(value, str), f"Value for key '{key}' is not a string: {type(value)}"
656+
657+
# Verify specific conversions
658+
expected_result = {
659+
"ansi_mode": "True", # boolean True -> "True", key lowercased
660+
"statement_timeout": "3600", # int -> "3600", key lowercased
661+
"timezone": "UTC", # string -> "UTC", key lowercased
662+
"enable_photon": "False", # boolean False -> "False", key lowercased
663+
"max_file_partition_bytes": "128.5", # float -> "128.5", key lowercased
664+
}
665+
666+
assert result == expected_result
667+
668+
# Test with None input
669+
assert _filter_session_configuration(None) is None
670+
671+
# Test with empty dict
672+
assert _filter_session_configuration({}) is None
673+
674+
# Test with only unsupported parameters
675+
unsupported_config = {
676+
"unsupported_param1": "value1",
677+
"unsupported_param2": 123,
678+
}
679+
result = _filter_session_configuration(unsupported_config)
680+
assert result == {}
681+
682+
# Test case insensitivity for keys
683+
case_insensitive_config = {
684+
"ansi_mode": "false", # lowercase key
685+
"STATEMENT_TIMEOUT": 7200, # uppercase key
686+
"TiMeZoNe": "America/New_York", # mixed case key
687+
}
688+
result = _filter_session_configuration(case_insensitive_config)
689+
expected_case_result = {
690+
"ansi_mode": "false",
691+
"statement_timeout": "7200",
692+
"timezone": "America/New_York",
693+
}
694+
assert result == expected_case_result
695+
696+
# Verify all values are strings in case insensitive test
697+
for key, value in result.items():
698+
assert isinstance(value, str), f"Value for key '{key}' is not a string: {type(value)}"
699+
636700
def test_results_message_to_execute_response_is_staging_operation(self, sea_client):
637701
"""Test that is_staging_operation is correctly set from manifest.is_volume_operation."""
638702
# Test when is_volume_operation is True

0 commit comments

Comments
 (0)