diff --git a/nodes/test/mocks/chromadb/__init__.py b/nodes/test/mocks/chromadb/__init__.py index e3260420f..ca8c11c21 100644 --- a/nodes/test/mocks/chromadb/__init__.py +++ b/nodes/test/mocks/chromadb/__init__.py @@ -150,7 +150,7 @@ def get( items = list(self._storage.items()) # Filter by ids if provided - if ids: + if ids is not None: items = [(id, data) for id, data in items if id in ids] count = 0 @@ -214,7 +214,7 @@ def add( def delete(self, ids: List[str] = None, where: Optional[Dict] = None): """Delete items from the collection.""" - if ids: + if ids is not None: for id in ids: if id in self._storage: del self._storage[id] @@ -228,7 +228,7 @@ def delete(self, ids: List[str] = None, where: Optional[Dict] = None): def update(self, ids: List[str] = None, where: Optional[Dict] = None, new_metadata: Dict = None): """Update items in the collection.""" - if ids: + if ids is not None: for id in ids: if id in self._storage and new_metadata: self._storage[id]['metadata'].update(new_metadata) diff --git a/nodes/test/mocks/psycopg2/__init__.py b/nodes/test/mocks/psycopg2/__init__.py index 054d64667..6f3597e51 100644 --- a/nodes/test/mocks/psycopg2/__init__.py +++ b/nodes/test/mocks/psycopg2/__init__.py @@ -154,7 +154,7 @@ def _handle_select_query(self, query: str, params: Tuple): # Apply LIMIT limit = self._extract_limit(query, params) - if limit: + if limit is not None: results = results[:limit] self._results = results @@ -182,7 +182,7 @@ def _handle_semantic_search(self, query: str, params: Tuple): query_vector = p.tolist() elif isinstance(p, (list, tuple)) and len(p) > 3: query_vector = list(p) - elif isinstance(p, int) and p < 1000: + elif isinstance(p, int) and not isinstance(p, bool) and p < 1000: limit = p else: filter_params.append(p) @@ -318,7 +318,7 @@ def _extract_limit(self, query: str, params: Tuple) -> Optional[int]: if 'limit' in query.lower() and params: # Last param is often the limit for p in reversed(params): - if isinstance(p, int) and p < 10000: + if isinstance(p, int) and not isinstance(p, bool) and p < 10000: return p return None @@ -331,7 +331,7 @@ def _matches_where_params(self, data: Dict, params: List) -> bool: """Check if data matches filter parameters.""" # Check isDeleted is_deleted = data.get('isdeleted', False) - if False in params and is_deleted: + if any(p is False for p in params) and is_deleted: return False return True diff --git a/nodes/test/mocks/weaviate/__init__.py b/nodes/test/mocks/weaviate/__init__.py index 6c6d44d4e..49cfcea22 100644 --- a/nodes/test/mocks/weaviate/__init__.py +++ b/nodes/test/mocks/weaviate/__init__.py @@ -133,7 +133,7 @@ def matches(self, properties: Dict[str, Any]) -> bool: elif op == 'like': # Simple wildcard matching pattern = value.replace('*', '') - results.append(pattern.lower() in str(prop_value).lower() if prop_value else False) + results.append(pattern.lower() in str(prop_value).lower() if prop_value is not None else False) elif op == 'greater_or_equal': results.append(prop_value >= value if prop_value is not None else False) elif op == 'less_or_equal':