
    Goh'                     N   d dl Z d dlZ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 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 d dlmZ d dlmZ ej(                  j+                  d e j(                  j-                  edz                 G d dej0                        Z G d dej0                        Z G d dej0                        Z G d dej0                        Z G d dej0                        Z G d dej0                        Zedk(  r ej@                          yy)    N)defaultdict)patch)UUID)uuid4)cli)decode)encode)get_alphabet)random)set_alphabet	ShortUUID)uuidz/../..c                   *    e Zd Zd Zd Zd Zd Zd Zy)LegacyShortUUIDTestc                    | j                  dt        t                     cxk  xr dk  nc        | j                  dt        t        d            cxk  xr dk  nc        | j                  dt        t        d            cxk  xr dk  nc        | j                  dt        t        d            cxk  xr
 dk         y c        y N      zhttp://www.example.com/zHTTP://www.example.com/zexample.com/)
assertTruelenr   )selfs    t/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/shortuuid/test_shortuuid.pytest_generationz#LegacyShortUUIDTest.test_generation   s    S[-2-.S&?!@AFBFGS&?!@AFBFGSn!56;;<;<    c                 P    t        d      }| j                  t        |      d       y Nz&{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}CXc85b4rqinB7s5J52TRYb)r   assertEqualr	   r   us     r   test_encodingz!LegacyShortUUIDTest.test_encoding   s"    9:$<=r   c                 P    t        d      }| j                  t        d      |       y r   )r   r   r   r    s     r   test_decodingz!LegacyShortUUIDTest.test_decoding!   s#    9: 891=r   c                    t               }d}t        |       | j                  |t                      t        d       | j                  |t                      | j                  t        t	                     t        d             | j                  dt        t	                     cxk  xr dk  nc        t               }| j                  |t        t        |                   t	               }| j                  |t        t        |                   | j                  t        t        d       | j                  t        t        d       t        |       | j                  t        d d       y )	N0101010101010101t      11111111c                     t        |       S )Nr   )xs    r   <lambda>z3LegacyShortUUIDTest.test_alphabet.<locals>.<lambda>=   s
    	! r   0)r
   r   r   setr   r   r   r   r   r	   assertRaises
ValueError)r   backup_alphabetalphabetr!   s       r   test_alphabetz!LegacyShortUUIDTest.test_alphabet%   s    &.X<>2%&<>2TVc$i0c$&k/C/0GF6!9-.FF6!9-.*lC8*lI>_%*&<cBr   c                     | j                  t        t                     d       t        dd      D ]&  }| j                  t        t        |            |       ( y )N      d   )r   r   r   range)r   is     r   test_randomzLegacyShortUUIDTest.test_random?   sE    VX+q# 	0AS^Q/	0r   N)__name__
__module____qualname__r   r"   r$   r5   r<    r   r   r   r      s    =>>C40r   r   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)ClassShortUUIDTestc                    t               }| j                  dt        |j                               cxk  xr dk  nc        | j                  dt        |j                  d            cxk  xr dk  nc        | j                  dt        |j                  d            cxk  xr dk  nc        | j                  dt        |j                  d            cxk  xr
 dk         y c        y r   )r   r   r   r   r   sus     r   r   z"ClassShortUUIDTest.test_generationF   s    [S^0b01S)B!CDIrIJS)B!CDIrIJS!89>B>?>?r   c                 p    t               }t        d      }| j                  |j                  |      d       y r   )r   r   r   r	   r   rE   r!   s      r   r"   z ClassShortUUIDTest.test_encodingM   s-    [9:1'?@r   c                 p    t               }t        d      }| j                  |j                  d      |       y r   )r   r   r   r   rG   s      r   r$   z ClassShortUUIDTest.test_decodingR   s.    [9:#;<a@r   c                     t               }t        d      D ]+  }| j                  t        |j	                               d       - t        dd      D ],  }| j                  t        |j	                  |            |       . y )N  r7   r8   r9   )r   r:   r   r   r   )r   rE   r;   s      r   r<   zClassShortUUIDTest.test_randomW   sk    [t 	3AS-r2	3 q# 	3AS1.2	3r   c                    d}t        |      }t               }| j                  ||j                                |j                  d       | j                  ||j                                | j                  t	        |j                               t	        d             | j                  dt        |j                               cxk  xr dk  nc        | j                  dt        |j                               cxk  xr dk  nc        t               }| j                  ||j                  |j                  |                   |j                         }| j                  ||j                  |j                  |                   | j                  t        |j                  d       | j                  t        |j                  d       y )	Nr&   r'   r(   r)   r   r   r*   r+   )r   r   r
   r   r0   r   r   r   r   r   r	   r1   r2   )r   r4   su1su2r!   s        r   r5   z ClassShortUUIDTest.test_alphabet_   s;   !k3#3#3#56)*3#3#3#56SXXZ#d)4c#((*o334S_1r12GCJJszz!}56HHJCJJszz!}56*c&6&6<*c&6&6	Br   c                    t               }| j                  |j                         d       t        j                  t        j
                  z   t        j                  z   dz   }t        |      }| j                  |j                         d       d}t        |      }| j                  |j                         d       t               }| j                  |j                  d      d       y )Nr7   z+/r&         )	num_bytes   )r   r   encoded_lengthstringascii_uppercaseascii_lowercasedigits)r   rL   base64_alphabetrM   binary_alphabetsu3su4s          r   test_encoded_lengthz&ClassShortUUIDTest.test_encoded_lengthv   s    k++-r2 ""V%;%;;fmmKdR 	 (++-r2(++-s3k++a+8"=r   N)	r=   r>   r?   r   r"   r$   r<   r5   r\   r@   r   r   rB   rB   E   s$    @A
A
3C.>r   rB   c                       e Zd Zd Zd Zd Zy)ShortUUIDPaddingTestc                     t               }t               }t        d      }|j                  |      }|j                  |      }| j	                  t        |      t        |             y Nr   )int)r   r   r   r	   r   r   r   rE   
random_uidsmallest_uidencoded_randomencoded_smalls         r   test_paddingz!ShortUUIDPaddingTest.test_padding   sO    [W
{:.		,/^,c-.@Ar   c                    t               }t               }t        d      }|j                  |      }|j                  |      }| j	                  |j                  |      |       | j	                  |j                  |      |       y r`   )r   r   r   r	   r   r   rb   s         r   r$   z"ShortUUIDPaddingTest.test_decoding   sg    [W
{:.		,/=1<@>2J?r   c                    t               }d}t        t              }t        |      D ]V  }t	               }|j                  |      }|t        |      xx   dz  cc<   |j                  |      }| j                  ||       X | j                  t        |      d       t        t        |j                                     }| j                  ||   |       y )NrJ   r8   )r   r   ra   r:   r   r	   r   r   r   nextiterkeys)	r   rE   num_iterationsuid_lengthscountrc   re   decoded_random
uid_lengths	            r   test_consistencyz%ShortUUIDPaddingTest.test_consistency   s    [!#&>* 	9EJYYz2NN+,1,YY~6NZ8	9 	[)1-${//123
Z0.Ar   N)r=   r>   r?   rg   r$   rr   r@   r   r   r^   r^      s    B	@Br   r^   c                       e Zd Zd Zy)EncodingEdgeCasesTestc                 b   t               }| j                  t        |j                  g        | j                  t        |j                  i        | j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  d       y N)   *   g      E@)r   r1   r2   r	   r   rD   s     r   test_decode_dictz&EncodingEdgeCasesTest.test_decode_dict   w    [*bii4*bii4*bii6*bii4*bii6r   Nr=   r>   r?   ry   r@   r   r   rt   rt          7r   rt   c                       e Zd Zd Zy)DecodingEdgeCasesTestc                 b   t               }| j                  t        |j                  g        | j                  t        |j                  i        | j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  d       y rv   )r   r1   r2   r   rD   s     r   ry   z&DecodingEdgeCasesTest.test_decode_dict   rz   r   Nr{   r@   r   r   r~   r~      r|   r   r~   c                   `    e Zd Z ed      d        Z ed      d        Z ed      d        Zy)CliTestzshortuuid.cli.printc                     t        g        |j                          |j                  d   d   }| j                  t	        |      d       y )Nr   r7   )r   assert_called	call_argsr   r   r   
mock_printterminal_outputs      r   $test_shortuuid_command_produces_uuidz,CliTest.test_shortuuid_command_produces_uuid   sA     	B  "$..q1!4_-r2r   c                 f    t        ddg       |j                  d   d   }| j                  |d       y )Nr	   $3b1f8b40-222c-4a6e-b77e-779d5a94e21cr   r   r   r   r   r   s      r   test_encode_commandzCliTest.test_encode_command   s6    X=>?$..q1!4*BCr   c                 f    t        ddg       |j                  d   d   }| j                  |d       y )Nr   r   r   r   r   r   s      r   test_decode_commandzCliTest.test_decode_command   s6    X/01$..q1!4*PQr   N)r=   r>   r?   r   r   r   r   r@   r   r   r   r      sR    
 !3 "3  !D "D  !R "Rr   r   __main__)!osrT   sysunittestcollectionsr   unittest.mockr   r   r   r   shortuuid.clir   shortuuid.mainr   r	   r
   r   r   r   pathinsertabspath__file__TestCaser   rB   r^   rt   r~   r   r=   mainr@   r   r   <module>r      s    	  
  #     ! ! ' ! ' $  277??8h#67 8,0(++ ,0^A>** A>H&B8,, &BR7H-- 77H-- 7Rh R2 zHMMO r   