
    h?C                         d dl 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 d dl	m
Z
mZ d dlmZ d dlZdd	lmZ  G d
 de
          ZdS )    N)Path)OperationalError)TemporaryDirectoryThread)IsolatedAsyncioTestCaseSkipTest)patch   setup_loggerc                       e Zd Zed             Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )	SmokeTestc                 "    t                       d S Nr   )clss    U/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/aiosqlite/tests/smoke.py
setUpClasszSmokeTest.setUpClass   s        c                     t                      }|                     |j                   t          |j                                                  dz  | _        d S )Nztest.db)r   
addCleanupcleanupr   nameresolvedb)selftds     r   setUpzSmokeTest.setUp   sE    !!
###rw--''))I5r   c                   K   t          j        | j                   d {V }|                     |t           j                   |                    d          4 d {V }|                                 d {V }|                     |dg           d d d           d {V  n# 1 d {V swxY w Y   |                                 d {V  d S Nselect 1, 2)r      )		aiosqliteconnectr   assertIsInstance
ConnectionexecutefetchallassertEqualcloser   r   cursorrowss       r   test_connection_awaitzSmokeTest.test_connection_await   sb     $TW--------b)"6777::m,, 	- 	- 	- 	- 	- 	- 	-********DTF8,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- hhjjs   2B!!
B+.B+c                   K   t          j        | j                  4 d {V }|                     |t           j                   |                    d          4 d {V }|                                 d {V }|                     |dg           d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  d S # 1 d {V swxY w Y   d S r    )r#   r$   r   r%   r&   r'   r(   r)   r+   s       r   test_connection_contextz!SmokeTest.test_connection_context%   s     $TW-- 	1 	1 	1 	1 	1 	1 	1!!"i&:;;;zz-00 1 1 1 1 1 1 1F#__........  x0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s5   <C2B"C"
B,	,C/B,	0C
CCc                 `  K   | j                                          G fdd          }t                                                     |            f}t	          j        |d                   4 d {V }|                    d           d {V  |                    d           d {V  |                                 d {V  |                    d           d {V }|                                 d {V }d d d           d {V  n# 1 d {V swxY w Y   |D ]}t	          j        |          4 d {V }|                    d           d {V }| 	                    |                                 d {V |           d d d           d {V  n# 1 d {V swxY w Y   d S )Nc                       e Zd Z fdZdS )1SmokeTest.test_connection_locations.<locals>.Fakec                     S r    )r   TEST_DBs    r   __str__z9SmokeTest.test_connection_locations.<locals>.Fake.__str__1   s    r   N)__name__
__module____qualname__r7   )r6   s   r   Faker3   0   s.              r   r;   r   z'create table foo (i integer, k integer)z$insert into foo (i, k) values (1, 5)select * from foo)
r   as_posixr   encoder#   r$   r'   commitr(   r)   )r   r;   locsr   r,   r-   locr6   s          @r   test_connection_locationsz#SmokeTest.test_connection_locations-   s7     '""$$	 	 	 	 	 	 	 	 	 	 Ww(8(8$$&&A$T!W-- 	+ 	+ 	+ 	+ 	+ 	+ 	+**FGGGGGGGGG**CDDDDDDDDD))++::&9::::::::F********D	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+  	@ 	@C (-- @ @ @ @ @ @ @!zz*=>>>>>>>>  v'8'8!8!8!8!8!8!8$???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@s&   9BD
DD A
F
F&	)F&	c                 H   K   t          j         j                  4 d {V }|                    d           d {V  d d d           d {V  n# 1 d {V swxY w Y    fdt	          j        fdt          d          D               d {V  t          j         j                  4 d {V }|                    d           d {V }|                                 d {V }d d d           d {V  n# 1 d {V swxY w Y   t          |          dk    sJ d S )NzHcreate table multiple_connections (i integer primary key asc, k integer)c                   K   t          j        j                  4 d {V }|                    d| g           d {V  |                                 d {V  d d d           d {V  d S # 1 d {V swxY w Y   d S )Nz/insert into multiple_connections (k) values (?))r#   r$   r   r'   r?   )ir   r   s     r   do_one_connz8SmokeTest.test_multiple_connections.<locals>.do_one_connJ   s       (11 " " " " " " "Rjj!RUVTWXXXXXXXXXiikk!!!!!!!" " " " " " " " " " " " " " " " " " " " " " " " " " " " " "s   8A..
A8;A8c                 &    g | ]} |          S r5   r5   ).0rE   rF   s     r   
<listcomp>z7SmokeTest.test_multiple_connections.<locals>.<listcomp>O   s!    AAA!{{1~~AAAr   
   z"select * from multiple_connections)	r#   r$   r   r'   asynciogatherranger(   len)r   r   r,   r-   rF   s   `   @r   test_multiple_connectionsz#SmokeTest.test_multiple_connectionsC   sr     $TW-- 	 	 	 	 	 	 	**9        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 		" 	" 	" 	" 	"
 nAAAAuRyyAAABBBBBBBB$TW-- 	+ 	+ 	+ 	+ 	+ 	+ 	+::&JKKKKKKKKF********D	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 4yyBs#   A
AA46C<<
D	Dc                 p  K   t          j        | j                  4 d {V                     d           d {V  t	          j        fdt          d          D               d {V                                   d {V  d d d           d {V  n# 1 d {V swxY w Y   t          j        | j                  4 d {V                     d           d {V }|                                 d {V }d d d           d {V  n# 1 d {V swxY w Y   t          |          dk    sJ d S )NzDcreate table multiple_queries (i integer primary key asc, k integer)c                 >    g | ]}                     d |g          S )z+insert into multiple_queries (k) values (?))r'   )rH   rE   r   s     r   rI   z3SmokeTest.test_multiple_queries.<locals>.<listcomp>_   s:        JJLqcRR  r   rJ   zselect * from multiple_queries)
r#   r$   r   r'   rK   rL   rM   r?   r(   rN   )r   r,   r-   r   s      @r   test_multiple_querieszSmokeTest.test_multiple_queriesW   s     $TW-- 	 	 	 	 	 	 	**9        
 .   "2YY          ))++	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 $TW-- 	+ 	+ 	+ 	+ 	+ 	+ 	+::&FGGGGGGGGF********D	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 4yyBs$   A#B
B"%B"6D
DDc                   K   t          j        | j                  4 d {V }|                                 d {V }|                    d           d {V  |                    dd t          d          D                        d {V  |                                 d {V  d d d           d {V  n# 1 d {V swxY w Y   t          j        | j                  4 d {V }|                    d           d {V }g }|2 3 d {V }|                    |           6 	 d d d           d {V  n# 1 d {V swxY w Y   t          |          dk    sJ d S )NzCcreate table iterable_cursor (i integer primary key asc, k integer)z*insert into iterable_cursor (k) values (?)c                     g | ]}|gS r5   r5   rH   rE   s     r   rI   z2SmokeTest.test_iterable_cursor.<locals>.<listcomp>t   s    >V>V>Vqs>V>V>Vr   rJ   zselect * from iterable_cursor
r#   r$   r   r,   r'   executemanyrM   r?   appendrN   r   r   r,   r-   rows        r   test_iterable_cursorzSmokeTest.test_iterable_cursorm   s     $TW-- 	 	 	 	 	 	 	99;;&&&&&&F..X         $$<>V>VERTII>V>V>V         ))++	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 $TW-- 	! 	! 	! 	! 	! 	! 	!::&EFFFFFFFFFD# ! ! ! ! ! ! !cC     $V	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 4yyBs0   BB77
CC' D8D$D88
EEc                    K   i  fdt          j        d          4 d {V                     d           d {V                      dd           d {V                                   d {V  fdt	          d          D             }|D ]}|                                 |D ]}|                                 	 d d d           d {V  n# 1 d {V swxY w Y                        t                    d           	                                D ]%}                     t          |          d           &d S )	Nc                    fd}                     |           5  t          j                    }|                     |                      }|                                 || <   d d d            d S # 1 swxY w Y   d S )Nc                    K                        d          4 d {V } |                                  d {V }                    t          |          d           |cd d d           d {V  S # 1 d {V swxY w Y   d S )Nr<   r"   )r'   r(   r)   rN   )r,   r-   connr   s     r   queryz>SmokeTest.test_multi_loop_usage.<locals>.runner.<locals>.query   s     <<(;<<              !'!2!2222222D$$SYY222                                                           s   ?A11
A;>A;)subTestrK   new_event_looprun_until_completer*   )kr_   r`   loopr-   resultsr   s    `   r   runnerz/SmokeTest.test_multi_loop_usage.<locals>.runner   s                a " "-//..uuww77

!
	" " " " " " " " " " " " " " " " " "s   A
A55A9<A9:memory:z'create table foo (id int, name varchar)z%insert into foo values (?, ?), (?, ?))r   Sallyr"   Janetc                 6    g | ]}t          |f           S ))targetargsr   )rH   rd   r   rg   s     r   rI   z3SmokeTest.test_multi_loop_usage.<locals>.<listcomp>   s*    MMMqvV1b':::MMMr      r"   )
r#   r$   r'   r?   rM   startjoinr)   rN   values)r   threadsthreadr-   r   rf   rg   s   `   @@@r   test_multi_loop_usagezSmokeTest.test_multi_loop_usage   s0     	" 	" 	" 	" 	" 	" $Z00 	 	 	 	 	 	 	B**FGGGGGGGGG**79Q         ))++MMMMME!HHMMMG!  !  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Wq)))NN$$ 	+ 	+DSYY****	+ 	+s   B C
C&)C&c           	      P  K   t          j        | j                  4 d {V }|                                4 d {V }|                    d           d {V  |                    dd t          d          D                        d {V  |                                 d {V  d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  n# 1 d {V swxY w Y   t          j        | j                  4 d {V }|                    d          4 d {V }g }|2 3 d {V }|                    |           6 	 d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  n# 1 d {V swxY w Y   t          |          dk    sJ d S )NzBcreate table context_cursor (i integer primary key asc, k integer)z)insert into context_cursor (k) values (?)c                     g | ]}|gS r5   r5   rU   s     r   rI   z1SmokeTest.test_context_cursor.<locals>.<listcomp>   s    ,,,QaS,,,r   rJ   zselect * from context_cursorrV   rY   s        r   test_context_cursorzSmokeTest.test_context_cursor   s     $TW-- 
	" 
	" 
	" 
	" 
	" 
	" 
	"yy{{ 	" 	" 	" 	" 	" 	" 	"fnn=         ((?,,%)),,,         iikk!!!!!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" 
	" $TW-- 	% 	% 	% 	% 	% 	% 	%zz"@AA % % % % % % %V!' % % % % % % %#KK$$$$ "(% % % % % % % % % % % % % % % % % % % % % % % % % % %	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 4yyBsw   CA)B8&C8
C	CC	C
C%(C%F 'E,E	2EF 
E'	'F *E'	+F  
F
F
c                   K   t          j        | j                  4 d {V }|                                 d {V }|                    d           d {V }|                     ||d           |                    dddg           d {V }|                     ||           |                    d           d {V }|                     ||           d d d           d {V  d S # 1 d {V swxY w Y   d S )Nz;create table test_cursor_return_self (i integer, k integer)zcursor execute returns itselfz1insert into test_cursor_return_self values (?, ?))r   r   )r"   r"   zinsert into test_cursor_return_self values (3, 3);insert into test_cursor_return_self values (4, 4);insert into test_cursor_return_self values (5, 5);)r#   r$   r   r,   r'   r)   rW   executescript)r   r   r,   results       r   test_cursor_return_selfz!SmokeTest.test_cursor_return_self   s     $TW-- 	- 	- 	- 	- 	- 	- 	-99;;&&&&&&F!>>M       F VV-LMMM!--CffEU       F VV,,,!//E       F
 VV,,,%	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   B2C''
C14C1c                 "
  K   t          j        | j                  4 d {V }|                     |j        d           |                                4 d {V }|                     |j                   |                    d           d {V  |                    d           d {V  | 	                    |j                   |
                                 d {V  |                     |j                   d d d           d {V  n# 1 d {V swxY w Y   |                     |j        d           |                     |j                   |                     |j        t                     |                                4 d {V }|                    d           d {V  |                                 d {V }|                     |t"                     |                     |d           |                     t&                    5  |d         }d d d            n# 1 swxY w Y   d d d           d {V  n# 1 d {V swxY w Y   |                                4 d {V }t           j        |_        |                     |j        t           j                   |                    d           d {V  |                                 d {V }|                     |t           j                   |                     |d         d           |                     |d         d	           |                     |d         d           |                     |d
         d	           d d d           d {V  n# 1 d {V swxY w Y   t           j        |_        t*          |_        |                     |j        t           j                   |                     |j        t*                     |                                4 d {V }|                    d           d {V  |                                 d {V }|                     |t           j                   |                     |d         d           |                     |d         d           |                     |d         d           |                     |d
         d           d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  d S # 1 d {V swxY w Y   d S )Nr   zKcreate table test_properties (i integer primary key asc, k integer, d text)z3insert into test_properties (k, d) values (1, 'hi')r   zselect * from test_properties)r   r   hird   r"   r}   ds   hi)r#   r$   r   r)   total_changesr,   assertFalsein_transactionr'   
assertTruer?   assertIsNonerow_factorytext_factorystrfetchoner%   tupleassertRaises	TypeErrorRowbytes)r   r   r,   rZ   _s        r   test_connection_propertiesz$SmokeTest.test_connection_properties   s     $TW-- 4	2 4	2 4	2 4	2 4	2 4	2 4	2R-q111yy{{ 4 4 4 4 4 4 4f  !2333nnE         nnI          1222iikk!!!!!!!  !23334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 R-q111bn---R_c222yy{{ ! ! ! ! ! ! !fnn%DEEEEEEEEE"OO--------%%c5111  l333&&y11 ! !CA! ! ! ! ! ! ! ! ! ! ! ! ! ! !! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! yy{{ 	1 	1 	1 	1 	1 	1 	1f%.]"  !3Y]CCCnn%DEEEEEEEEE"OO--------%%c9=999  Q+++  Q...  S1---  S4000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 ']BN#BOR^Y];;;R_e444yy{{ 2 2 2 2 2 2 2fnn%DEEEEEEEEE"OO--------%%c9=999  Q+++  Q///  S1---  S51112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2[4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2 4	2s   6S>BD	7S>	
D	S>D	A2S>	BH<
	HH<H##H<&H#'H<*S><
I	S>	I	
S>'C<M5#S>5
M?	?S>M?	A?S>CSS>
S$	$S>'S$	(S>>
TTc                 R  K   t          j        | j                  4 d {V }|                    d           d {V  |                    d           d {V  |                                 d {V  d d d           d {V  n# 1 d {V swxY w Y   t          j        | j                  4 d {V }|                    d           d {V }|                                 d {V }|                     |g d           d d d           d {V  d S # 1 d {V swxY w Y   d S )NzBcreate table test_fetch_all (i integer primary key asc, k integer)z<insert into test_fetch_all (k) values (10), (24), (16), (32)z)select k from test_fetch_all where k < 30))rJ   )   )   )r#   r$   r   r'   r?   r(   r)   r+   s       r   test_fetch_allzSmokeTest.test_fetch_all  s     $TW-- 	 	 	 	 	 	 	**T         **N         ))++	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 $TW-- 	: 	: 	: 	: 	: 	: 	:::&QRRRRRRRRF********DT#8#8#8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s%   AB
BB5AD
D #D c                   K   t          j        | j                  4 d{V }	 |                    d           d{V  |                    d           d{V  n?# t
          $ r}d|j        vsJ Y d}~n%d}~wt          $ r}t          d          |d}~ww xY wddd          d{V  dS # 1 d{V swxY w Y   dS )z@Assert that after enabling extension loading, they can be loadedNTtestznot authorizedzKpython was not compiled with sqlite3 extension support, so we can't test it)	r#   r$   r   enable_load_extensionload_extensionr   rm   AttributeErrorr	   )r   r   es      r   test_enable_load_extensionz$SmokeTest.test_enable_load_extension  s     $TW-- 
	 
	 
	 
	 
	 
	 
		..t444444444''//////////# 6 6 6'qv555555555!   =  
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	sF   B-6AB-
B%A50B-5BBBB--
B7:B7c                 f  K   t          j        | j                  4 d{V }|                    d d           d{V  |                     t
                    5  |                    d           d{V  ddd           n# 1 swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS )ze
        Assert that after setting a progress handler returning 1, DB operations are aborted
        Nc                      dS )Nr   r5   r5   r   r   <lambda>z5SmokeTest.test_set_progress_handler.<locals>.<lambda>$  s    ! r   r   zIcreate table test_progress_handler (i integer primary key asc, k integer))r#   r$   r   set_progress_handlerr   r   r'   r   r   s     r   test_set_progress_handlerz#SmokeTest.test_set_progress_handler  s      $TW-- 	 	 	 	 	 	 	))))Q777777777""#344  jj_                      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s5   8B B6B B	B 	B	
B  
B*-B*c                   K   d }d }t          j        | j                  4 d{V }|                    dd|           d{V  |                    dd|           d{V  |                    d          4 d{V }|                                 d{V }|                     |d         d	           ddd          d{V  n# 1 d{V swxY w Y   |                    d
          4 d{V }|                                 d{V }|                     |d         d           ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS )z<Assert that after creating a custom function, it can be usedc                      dS )Nno argr5   r5   r   r   no_argz.SmokeTest.test_create_function.<locals>.no_arg-  s    8r   c                     | dz  S Nr"   r5   nums    r   one_argz/SmokeTest.test_create_function.<locals>.one_arg0      7Nr   Nr   r   r   r   zSELECT no_arg();r   zSELECT one_arg(10);   )r#   r$   r   create_functionr'   r   r)   )r   r   r   r   resrZ   s         r   test_create_functionzSmokeTest.test_create_function*  s:     	 	 		 	 	 $TW-- 
	- 
	- 
	- 
	- 
	- 
	- 
	-$$Xq&999999999$$Y7;;;;;;;;;zz"455 3 3 3 3 3 3 3LLNN******  Q2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 zz"788 - - - - - - -CLLNN******  Q,,,- - - - - - - - - - - - - - - - - - - - - - - - - - -
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	- 
	-sZ   AE >7C5E 
C	E C	E 37D<*E <
E	E 	E	
E  
E*-E*c                 B  K   d }t          j        | j                  4 d{V }|                    dd|d           d{V  |                    d           d{V  |                    d           d{V  ddd          d{V  dS # 1 d{V swxY w Y   dS )	zAssert that after creating a deterministic custom function, it can be used.

        https://sqlite.org/deterministic.html
        c                     | dz  S r   r5   r   s    r   r   z=SmokeTest.test_create_function_deterministic.<locals>.one_argE  r   r   Nr   r   T)deterministicz"create table foo (id int, bar int)z#create index t on foo(one_arg(bar)))r#   r$   r   r   r'   )r   r   r   s      r   "test_create_function_deterministicz,SmokeTest.test_create_function_deterministic?  s     	 	 	 $TW-- 	D 	D 	D 	D 	D 	D 	D$$Y7$$OOOOOOOOO**ABBBBBBBBB **BCCCCCCCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   AB
BBc                 J  K   g dt           ffd}t          j        | j                  4 d {V }|                    |           d {V  |                    d           d {V  |                     d           d d d           d {V  d S # 1 d {V swxY w Y   d S )N	statementc                 2                         |            d S r   )rX   )r   
statementss    r   callbackz3SmokeTest.test_set_trace_callback.<locals>.callbackR  s    i(((((r   z	select 10)r   r#   r$   r   set_trace_callbackr'   assertIn)r   r   r   r   s      @r   test_set_trace_callbackz!SmokeTest.test_set_trace_callbackO  s_     
	) 	) 	) 	) 	) 	) 	) $TW-- 	3 	3 	3 	3 	3 	3 	3''111111111**[)))))))))MM+z222		3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   AB
BBc                   K   t          d          }|                     t          d          5  t          j        |          4 d {V }|                     |           d d d           d {V  n# 1 d {V swxY w Y   d d d            n# 1 swxY w Y   |                     t          d          5  t          j        |           d {V  d d d            d S # 1 swxY w Y   d S )Nz!/something/that/shouldnt/exist.dbzunable to open database)r   assertRaisesRegexr   r#   r$   r   )r   bad_dbr   s      r   test_connect_errorzSmokeTest.test_connect_error[  s     9::##$46OPP 	& 	& (00 & & & & & & &B!!"%%%& & & & & & & & & & & & & & & & & & & & & & & & & & &	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& ##$46OPP 	, 	,#F+++++++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,sG   BA0B0
A:	:B=A:	>BBB3CC"Cc                   K   d }t          j        d d          }t          j        t          d|          5  |                     t          j        d          5  |4 d {V  	 d d d           d {V  n# 1 d {V swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |j        r#|	                                 t          d          d S )Nc                  *    t          j        d          )NI changed my mind)rK   CancelledError)r   __s     r   _raise_cancelled_errorzESmokeTest.test_connect_base_exception.<locals>._raise_cancelled_errorf  s    ()<===r   c                  *    t          j        d          S )Nrh   )sqlite3r$   r5   r   r   r   z7SmokeTest.test_connect_base_exception.<locals>.<lambda>i  s    '/*2M2M r   @   r$   )side_effectr   z!connection thread was not stopped)r#   r&   r
   objectr   r   rK   r   _running_stop_runningAssertionError)r   r   
connections      r   test_connect_base_exceptionz%SmokeTest.test_connect_base_exceptiond  s     	> 	> 	> )*M*MrRR
L)9OPPP	 	""7#9;NOO	 	 "                                  		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  	F$$&&& !DEEE	F 	FsY   !B*	B"A6$B6
B  BB BB*B	B*B	B**B.1B.c                 r  K   t          j        d          4 d {V }|                    d           d {V  |                    dddg           d {V  d |                                2              d {V }|                     |g d           d d d           d {V  d S # 1 d {V swxY w Y   d S )Nrh   ,create table foo (i integer, k charvar(250))insert into foo values (?, ?)r   hellor"   worldc                 "   K   g | 3 d {V }|
6 S r   r5   )rH   lines     r   rI   z+SmokeTest.test_iterdump.<locals>.<listcomp>|  s.      ::::::::DT::::s   )zBEGIN TRANSACTION;z-CREATE TABLE foo (i integer, k charvar(250));z$INSERT INTO "foo" VALUES(1,'hello');z$INSERT INTO "foo" VALUES(2,'world');zCOMMIT;)r#   r$   r'   rW   iterdumpr)   )r   r   liness      r   test_iterdumpzSmokeTest.test_iterdumpu  s     $Z00 	 	 	 	 	 	 	B**KLLLLLLLLL../,1M         ;:BKKMM:::::::::E  	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A6B&&
B03B0c                   K   t          j        | j                   d {V }|                    d           d {V }|                                 d {V  |                     t          d          5  |                                 d {V  d d d            n# 1 swxY w Y   |                     t          d          5  |                                 d {V  d d d            d S # 1 swxY w Y   d S )Nr!   zConnection closed)r#   r$   r   r'   r*   r   
ValueErrorr(   )r   r   r,   s      r    test_cursor_on_closed_connectionz*SmokeTest.test_cursor_on_closed_connection  s     $TW--------zz-00000000hhjj##J0CDD 	$ 	$//#########	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$##J0CDD 	$ 	$//#########	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s$   2BB B?C''C+.C+c                   K   t          j        | j                   d {V }|                    d           d {V }g }t	          d          D ]z}|dk    r9|                    t          j        |                                                     |                    t          j        |	                                                     {|D ] }	 | d {V  # t          j        $ r Y w xY wd S )Nr!   d   2   )r#   r$   r   r'   rM   rX   rK   ensure_futurer*   r(   r   ProgrammingError)r   r   r,   tasksrE   tasks         r   %test_cursor_on_closed_connection_loopz/SmokeTest.test_cursor_on_closed_connection_loop  s     $TW--------zz-00000000s 	C 	CABwwW2288::>>???LL.v/@/@AABBBB 	 	D







+   	 	s   CC)(C)c                    K   t          j        | j                   d {V }|                                 d {V  |                                 d {V  d S r   )r#   r$   r   r*   r   s     r   test_close_twicezSmokeTest.test_close_twice  sr      $TW--------hhjj hhjjr   c                 l  K   d }t          j        d          4 d {V 	 }t          j        d          4 d {V 	 }|                    d           d {V  |                    dddg           d {V  |                                 d {V  |                     t          d          5  |                    d           d {V  d d d            n# 1 swxY w Y   |                    ||	           d {V  |                    d          4 d {V }|                                 d {V }| 	                    |ddg           d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  d S # 1 d {V swxY w Y   d S )
Nc                 (    t          | ||           d S r   )print)abcs      r   progressz1SmokeTest.test_backup_aiosqlite.<locals>.progress  s    !QNNNNNr   rh   r   r   r   r   no such table: foor<   )r   )
r#   r$   r'   rW   r?   r   r   backupr(   r)   )r   r   db1db2r,   r-   s         r   test_backup_aiosqlitezSmokeTest.test_backup_aiosqlite  sS     	 	 	 j))	E 	E 	E 	E 	E 	E 	E 	E-0j))	E 	E 	E 	E 	E 	E 	E 	E-0++LMMMMMMMMM///,1M         **,,''(8:NOO 7 7kk"56666666667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 **S8*444444444{{#677 E E E E E E E6#__........  l'CDDDE E E E E E E E E E E E E E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	Es}   F#A/E?,CE?CE?C;E?3E
E?
E&&E?)E&*E?-F#?
F			F#F		F##
F-0F-c                   K   t          j        d          4 d {V }t          j        d          5 }|                    d           d {V  |                    dddg           d {V  |                                 d {V  |                     t          d          5  |                    d           d d d            n# 1 swxY w Y   |                    |           d {V  |                    d          }|	                                }| 
                    |ddg           d d d            n# 1 swxY w Y   d d d           d {V  d S # 1 d {V swxY w Y   d S )Nrh   r   r   r   r   r   r<   )r#   r$   r   r'   rW   r?   r   r   r   r(   r)   )r   r   r   r,   r-   s        r   test_backup_sqlitezSmokeTest.test_backup_sqlite  s     $Z00 	E 	E 	E 	E 	E 	E 	EC,, Ekk"PQQQQQQQQQoo3lL5Q         jjll"""""""++,<>RSS 5 5KK 34445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 jjoo%%%%%%%%899((  l'CDDDE E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	EsZ   EA/D6!C7D6CD6
CAD6*E6D:	:E=D:	>E
E!EN)r8   r9   r:   classmethodr   r   r.   r0   rB   rO   rR   r[   rt   rw   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r5   r   r   r   r      s         [6 6 6
  1 1 1@ @ @,  (  ,  &+ + +B  *- - -*52 52 52n: : :  	 	 	- - -*D D D 
3 
3 
3, , ,F F F"  &$ $ $    E E E.E E E E Er   r   )rK   r   pathlibr   r   tempfiler   	threadingr   unittestr   r	   unittest.mockr
   r#   helpersr   r   r5   r   r   <module>r      s            $ $ $ $ $ $ ' ' ' ' ' '       6 6 6 6 6 6 6 6           ! ! ! ! ! !E E E E E' E E E E Er   