
    _j                        d Z ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ ddlmZmZmZ d	ed
ee	ef         fdZej                            ee          d	ed
dfd            Zej                            ee          d	ed
dfd            Zej                            ee          d	ed
dfd            Zej                            ee          d	ed
dfd            ZdS )z9Tests for the Count API endpoint with read_level support.    )Tuple)uuid4N)	ClientAPI)
Collection)	ReadLevel)ClientFactoriesis_spann_disabled_modeskip_reason_spann_disabledclient_factoriesreturnc                     |                                  }|                                 dt                      j         }|                    |          }||fS )z(Create a test collection with some data.count_api_test_)name)create_client_from_systemresetr   hexget_or_create_collection)r   clientcollection_name
collections       ]/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/chromadb/test/api/test_count_api.py_create_test_collectionr      sV     7799F
LLNNN555O00o0FFJv    )reasonc                     t          |           \  }}|                    g dg dg dg dg dg           |                    t          j                  }|dk    sJ d	S )
zHTest count with ReadLevel.INDEX_AND_WAL (default) returns correct count.doc1doc2doc3zapple fruitzbanana fruitzcar vehicleg?皙?333333?皙?r"   r#   r$         ?g?皙?ffffff?333333?ids	documents
embeddings
read_level   N)r   addcountr   INDEX_AND_WALr   r   _r3   s       r   (test_count_with_read_level_index_and_walr7      s    
 ,,<==MJNN$$$@@@(((*>*>*>@T@T@TU     	(?@@EA::::::r   c                     t          |           \  }}|                    g dg dg dg dg dg           |                    t          j                  }t          |t                    sJ |dk    sJ d	S )
z;Test count with ReadLevel.INDEX_ONLY returns a valid count.r   r    r!   r%   r'   r+   r/   r   N)r   r2   r3   r   
INDEX_ONLY
isinstanceintr5   s       r   %test_count_with_read_level_index_onlyr<   0   s    
 ,,<==MJNN$$$@@@(((*>*>*>@T@T@TU     	(<==EeS!!!!!A::::::r   c                     t          |           \  }}|                    g dg dg dg dg dg           |                    t          j                  }t          |t                    sJ |dk    sJ d	S )
zFTest count with ReadLevel.INDEX_AND_BOUNDED_WAL returns a valid count.r   r    r!   r%   r'   r+   r/   r   N)r   r2   r3   r   INDEX_AND_BOUNDED_WALr:   r;   r5   s       r   0test_count_with_read_level_index_and_bounded_walr?   D   s    
 ,,<==MJNN$$$@@@(((*>*>*>@T@T@TU     	(GHHEeS!!!!!A::::::r   c                     t          |           \  }}|                    ddgddgg dg dg           |                                }|dk    sJ d	S )
zDTest count without explicit read_level uses default (INDEX_AND_WAL).r   r   zhello worldzgoodbye worldr!   )r&   r*   r)   r(   r+      N)r   r2   r3   r5   s       r   test_count_default_read_levelrB   X   sz    
 ,,<==MJNNV /2(((*>*>*>?     EA::::::r   )__doc__typingr   uuidr   pytestchromadb.apir   chromadb.api.models.Collectionr   chromadb.api.typesr   chromadb.test.conftestr   r	   r
   r   markskipifr7   r<   r?   rB    r   r   <module>rN      s   ? ?              " " " " " " 5 5 5 5 5 5 ( ( ( ( ( (         
%

:y !
 
 
 
 *3MNN%	   ON  *3MNN%	   ON& *3MNN%	   ON& *3MNN%	   ON  r   