
    Bvh                         d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZ d dlZdeddfd	Zdeddfd
ZdeddfdZdeddfdZde	deeef   ddfdZy)    N)DEFAULT_DATABASEDEFAULT_TENANT)ClientFactories)InvalidArgumentError)	GetResult)DictAnyclient_factoriesreturnc                 N   | j                         }|j                          | j                         }|j                  d       |j	                  t
        d       |j                  dddi       |j	                  t
        t               |j                  ddt        i       |j                         }t        |      dk(  sJ |d   j                  dk(  sJ |j                  |d   j                        }|j                  dt        ik(  sJ |j	                  t
        d       |j                         }t        |      dk(  sJ |d   j                  ddik(  sJ |j	                  t
        t               |j                         d   j                  ddi       |j	                  t
        d       |j                         d   j                  dd	i       |j	                  t
        t               |j                         }t        |      dk(  sJ |d   j                  ddik(  sJ |j	                  t
        d       |j                         }t        |      dk(  sJ |d   j                  dd	ik(  sJ |j	                  t
        t               |j                  d       |j                         }t        |      dk(  sJ |j	                  t
        d       |j                         }t        |      dk(  sJ |j                  d       |j                         }t        |      dk(  sJ y )
Ntest_dbtenantdatabase
collectionr   )metadata   r   default2test_db2)create_client_from_systemresetcreate_admin_client_from_systemcreate_database
set_tenantr   create_collectionr   list_collectionslennameget_collectionr   modifydelete_collection)r
   clientadmin_clientcollectionsr   s        S/RAG/venv/lib/python3.12/site-packages/chromadb/test/client/test_database_tenant.py test_database_tenant_collectionsr&   
   s   779F
LLN#CCEL  + ^i@
\Z4KL ^6FG
\ZAQ4RS ))+K{q   q>,...&&{1~':':;J:/?"@@@@ ^i@))+K{q   q>""z9&==== ^6FG
a ''*j1I'J
^i@
a ''*j1I'J ^6FG))+K{q   q>""z:&>>>>
^i@))+K{q   q>""z:&>>>> ^6FG
\*))+K{q   
^i@))+K{q   
\*))+K{q       c                    | j                         }|j                          | j                         }|j                  d       |j	                  d       |j                  d      }|j	                  t               |j                  d      }g dt        d      D cg c]  }g d c}g dd}g d	t        d      D cg c]  }g d
 c}g d	d} |j                  di |  |j                  di | |j                  ddg      }|d   |d   k(  sJ t        ||       |d   |d   k(  sJ |j                  ddg      }|d   |d   k(  sJ t        ||       |d   |d   k(  sJ y c c}w c c}w )Nr   )r   collection_newcollection_defaultabc   g      ?g       @g      @ids
embeddings	documentsr.   deg      @g      @g      @r3   r4   includer2   resrecords )r   r   r   r   set_databaser   r   rangeaddgetcheck_embeddings)	r
   r"   r#   coll_newcoll_default_records_newrecords_defaultr<   s	            r%   test_database_collections_addrI   H   s   779F
LLN $CCEL  + +''(89H !12++,@AL 05a919$K 05a919$O HLL; L'' ,,k:,
;Cu:U++++k2{{;7777


L+#>

?Cu:////o6{{;;;;3 : :s   E-?E2c                 X   | j                         }|j                          | j                         }|j                  d       |j                  d       |j	                  dd       |j	                  dd       |j                  dd       |j                  d      }|j                  dd       |j                  d      }g dt        d      D cg c]  }g d	 c}g dd
}g dt        d      D cg c]  }g d c}g dd
} |j                  di |  |j                  di | |j                  ddg      }|d   |d   k(  sJ t        ||       |d   |d   k(  sJ |j                  ddg      }|d   |d   k(  sJ t        ||       |d   |d   k(  sJ y c c}w c c}w )Ntest_tenant1test_tenant2r   )r   r   r   r+   r/   r0   r1   r5   r8   r3   r4   r9   r2   r;   r>   )r   r   r   create_tenantr   r   r   r@   rA   rB   rC   )	r
   r"   r#   coll_tenant1coll_tenant2rF   records_tenant1records_tenant2r<   s	            r%   test_tenant_collections_addrR   v   s   779F
LLN $CCEL~.~.  > B  > B ^i@++L9L
^i@++L9L 05a919$O 05a919$O L'' L'' 

L+#>

?Cu:////o6{{;;;;


L+#>

?Cu:////o6{{;;;;3 : :s   F"4F'c                 x   | j                         }|j                          | j                         }t        j                  t
        t        f      5  |j                  d       d d d        t        j                  t
        t        f      5  |j                  d       d d d        y # 1 sw Y   CxY w# 1 sw Y   y xY w)Nr,   )	r   r   r   pytestraises	Exceptionr   r   rM   )r
   r"   r#   s      r%   test_min_len_namerW      s    779F
LLN $CCEL		#78	9$$S) 
: 
	#78	9""3' 
:	9	 
:	9 
:	9s   B$	B0$B-0B9r<   r=   c                 Z    | d   t        j                  | d   |d         sJ y |d   J y )Nr3   )nparray_equalr;   s     r%   rC   rC      s<    
<$~~c,/1FGGG|$,,,r'   )rT   chromadb.configr   r   chromadb.test.conftestr   chromadb.errorsr   chromadb.api.typesr   typingr   r	   numpyrY   r&   rI   rR   rW   strrC   r>   r'   r%   <module>rb      s     < 2 0 (  ;! ;!4 ;!|+<O +< +<\,</ ,<d ,<^( (D (-) -d38n - -r'   