fix: Enhance dictionary access tests and refactor apply_json_filter function (#7335)
* refactor: streamline apply_json_filter function for improved clarity and performance - Simplified data extraction from Data objects and handled None inputs. - Enhanced dictionary access logic and removed redundant checks. - Improved handling of special cases for filter access, including nested and array structures. * test: enhance dictionary access tests with additional examples - Added new example cases to the test_basic_dict_access function to cover edge cases, including empty dictionaries and keys with spaces. - Improved test robustness by utilizing the @example decorator from hypothesis for better failure discovery.
This commit is contained in:
parent
d0e526d9f0
commit
7e65be32a3
2 changed files with 32 additions and 39 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import pytest
|
||||
from hypothesis import assume, given
|
||||
from hypothesis import assume, example, given
|
||||
from hypothesis import strategies as st
|
||||
from langflow.schema.data import Data
|
||||
from langflow.template.utils import apply_json_filter
|
||||
|
|
@ -16,6 +16,14 @@ def dict_strategy():
|
|||
|
||||
# Test basic dictionary access
|
||||
@given(data=st.dictionaries(st.text(), st.integers()), key=st.text())
|
||||
@example(
|
||||
data={" ": 0}, # or any other generated value
|
||||
key=" ",
|
||||
).via("discovered failure")
|
||||
@example(
|
||||
data={},
|
||||
key=" ",
|
||||
).via("discovered failure")
|
||||
def test_basic_dict_access(data, key):
|
||||
# Skip empty key tests which have special handling
|
||||
assume(key != "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue