Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7158d0576d | |||
| bb87a7b932 | |||
| f1c4e65d72 |
@@ -44,3 +44,4 @@ jobs:
|
||||
speckle_function_id: ${{ secrets.SPECKLE_FUNCTION_ID }}
|
||||
speckle_function_input_schema_file_path: ${{ env.FUNCTION_SCHEMA_FILE_NAME }}
|
||||
speckle_function_command: 'python -u main.py run'
|
||||
speckle_function_recommended_memory_mi: 5000
|
||||
|
||||
@@ -17,5 +17,4 @@ PREDICATE_METHOD_MAP = {
|
||||
"identical to": PropertyRules.is_identical_value.__name__,
|
||||
"contains": PropertyRules.is_parameter_value_containing.__name__,
|
||||
"does not contain": PropertyRules.is_parameter_value_not_containing.__name__,
|
||||
"is set": PropertyRules.is_parameter_value_not_empty.__name__,
|
||||
}
|
||||
|
||||
@@ -890,35 +890,3 @@ class PropertyRules:
|
||||
return PropertyRules.compare_values(
|
||||
parameter_value, value_to_match, case_sensitive=True, tolerance=0, allow_yes_no_bools=False, use_exact=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_parameter_value_not_empty(speckle_object: Base, parameter_name: str) -> bool:
|
||||
"""Checks if parameter exists and has a non-empty value.
|
||||
|
||||
Args:
|
||||
speckle_object: The Speckle object to check
|
||||
parameter_name: Name of the parameter to check
|
||||
|
||||
Returns:
|
||||
bool: True if parameter exists and has a non-empty value
|
||||
"""
|
||||
# Get the parameter value
|
||||
parameter_value = PropertyRules.get_parameter_value(speckle_object, parameter_name)
|
||||
|
||||
# Check if parameter exists
|
||||
if parameter_value is None:
|
||||
return False
|
||||
|
||||
# Check if value is an empty string
|
||||
if isinstance(parameter_value, str) and parameter_value.strip() == "":
|
||||
return False
|
||||
|
||||
# Check if value is an empty list or collection
|
||||
if hasattr(parameter_value, "__len__") and len(parameter_value) == 0:
|
||||
return False
|
||||
|
||||
# Additional check for "None" string which can sometimes appear in exports
|
||||
if isinstance(parameter_value, str) and parameter_value.lower() == "none":
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@@ -415,20 +415,3 @@ class TestParameterHandling:
|
||||
"""Test negative substring matching on parameter values."""
|
||||
v2_obj, _ = test_objects
|
||||
assert PropertyRules.is_parameter_value_not_containing(v2_obj, param_name, substring) == expected_result
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"param_name, expected_result",
|
||||
[
|
||||
("category", True), # Parameter exists with non-empty value
|
||||
("family", True), # Parameter exists with non-empty value
|
||||
("non_existent_param", False), # Parameter doesn't exist
|
||||
# The following would require setup with empty values
|
||||
# ("empty_string_param", False), # Parameter exists but has empty string value
|
||||
# ("none_string_param", False), # Parameter exists but has "None" string value
|
||||
],
|
||||
)
|
||||
def test_parameter_not_empty(self, test_objects, param_name, expected_result):
|
||||
"""Test 'not empty' check on parameter values."""
|
||||
v2_obj, _ = test_objects
|
||||
|
||||
assert PropertyRules.is_parameter_value_not_empty(v2_obj, param_name) == expected_result
|
||||
|
||||
Reference in New Issue
Block a user