HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/shortuuid/__pycache__/test_shortuuid.cpython-39.pyc
a

�,�h'�@sLddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZej�dej�ed��Gdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedk�rHe� �dS)�N)�defaultdict)�patch)�UUID)�uuid4)�cli)�decode)�encode)�get_alphabet)�random)�set_alphabet��	ShortUUID)�uuidz/../..c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�LegacyShortUUIDTestcCs�|�dtt��kodkn�|�dttd��koBdkn�|�dttd��kohdkn�|�dttd��ko�dkn�dS�N��zhttp://www.example.com/zHTTP://www.example.com/zexample.com/)�
assertTrue�lenr)�self�r�I/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/shortuuid/test_shortuuid.py�test_generations$&&z#LegacyShortUUIDTest.test_generationcCstd�}|�t|�d�dS�Nz&{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}�CXc85b4rqinB7s5J52TRYb)r�assertEqualr�r�urrr�
test_encodingsz!LegacyShortUUIDTest.test_encodingcCstd�}|�td�|�dSr)rrrrrrr�
test_decoding!sz!LegacyShortUUIDTest.test_decodingcCs�t�}d}t|�|�|t��td�|�|t��|�tt��td��|�dtt��kohdkn�t�}|�|tt	|���t�}|�|t	t|���|�
ttd�|�
ttd�t|�|�
tdd�d	�dS)
N�01�01010101010101�t��1�1111111cSst|�S)Nr)�xrrr�<lambda>=�z3LegacyShortUUIDTest.test_alphabet.<locals>.<lambda>�0)r	rr�setrrrrrr�assertRaises�
ValueError)rZbackup_alphabet�alphabetrrrr�
test_alphabet%s $z!LegacyShortUUIDTest.test_alphabetcCs:|�tt��d�tdd�D]}|�tt|��|�qdS)N���d)rrr
�range)r�irrr�test_random?szLegacyShortUUIDTest.test_randomN)�__name__�
__module__�__qualname__rrrr.r4rrrrrs
rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ClassShortUUIDTestcCs�t�}|�dt|���ko$dkn�|�dt|�d��koLdkn�|�dt|�d��kotdkn�|�dt|�d��ko�dkn�dSr)r
rrr�r�surrrrFs
&((z"ClassShortUUIDTest.test_generationcCs$t�}td�}|�|�|�d�dSr)r
rrr�rr:rrrrrMsz ClassShortUUIDTest.test_encodingcCs$t�}td�}|�|�d�|�dSr)r
rrrr;rrrrRsz ClassShortUUIDTest.test_decodingcCsRt�}td�D]}|�t|���d�qtdd�D]}|�t|�|��|�q2dS)N��r/r0r1)r
r2rrr
)rr:r3rrrr4Ws
zClassShortUUIDTest.test_randomcCsd}t|�}t�}|�||���|�d�|�||���|�t|���td��|�dt|���kordkn�|�dt|���ko�dkn�t�}|�||�	|�
|���|��}|�||�
|�	|���|�t|jd�|�t|jd�dS)	Nr r!r"r#rrr$r%)
r
rr	rr*rrrrrrr+r,)rr-�su1�su2rrrrr._s
&&z ClassShortUUIDTest.test_alphabetcCs~t�}|�|��d�tjtjtjd}t|�}|�|��d�d}t|�}|�|��d�t�}|�|jdd�d�dS)Nr/z+/r ��)�	num_bytes�)r
rZencoded_length�string�ascii_uppercase�ascii_lowercase�digits)rr=Zbase64_alphabetr>Zbinary_alphabetZsu3Zsu4rrr�test_encoded_lengthvs�z&ClassShortUUIDTest.test_encoded_lengthN)	r5r6r7rrrr4r.rGrrrrr8Esr8c@s$eZdZdd�Zdd�Zdd�ZdS)�ShortUUIDPaddingTestcCsBt�}t�}tdd�}|�|�}|�|�}|�t|�t|��dS�Nr)�int)r
rrrrr�rr:�
random_uidZsmallest_uid�encoded_randomZ
encoded_smallrrr�test_padding�s


z!ShortUUIDPaddingTest.test_paddingcCsRt�}t�}tdd�}|�|�}|�|�}|�|�|�|�|�|�|�|�dSrI)r
rrrrrrKrrrr�s


z"ShortUUIDPaddingTest.test_decodingc	Cs�t�}d}tt�}t|�D]>}t�}|�|�}|t|�d7<|�|�}|�||�q|�t|�d�t	t
|����}|�|||�dS)Nr<r0)r
rrJr2rrrrr�next�iter�keys)	rr:Znum_iterationsZuid_lengths�countrLrMZdecoded_randomZ
uid_lengthrrr�test_consistency�s

z%ShortUUIDPaddingTest.test_consistencyN)r5r6r7rNrrSrrrrrH�s
rHc@seZdZdd�ZdS)�EncodingEdgeCasesTestcCsZt�}|�t|jg�|�t|ji�|�t|jd�|�t|jd�|�t|jd�dS�N)��*gE@)r
r+r,rrr9rrr�test_decode_dict�sz&EncodingEdgeCasesTest.test_decode_dictN�r5r6r7rXrrrrrT�srTc@seZdZdd�ZdS)�DecodingEdgeCasesTestcCsZt�}|�t|jg�|�t|ji�|�t|jd�|�t|jd�|�t|jd�dSrU)r
r+r,rr9rrrrX�sz&DecodingEdgeCasesTest.test_decode_dictNrYrrrrrZ�srZc@s<eZdZed�dd��Zed�dd��Zed�dd��ZdS)	�CliTestzshortuuid.cli.printcCs2tg�|��|jdd}|�t|�d�dS)Nrr/)rZ
assert_called�	call_argsrr�rZ
mock_printZterminal_outputrrr�$test_shortuuid_command_produces_uuid�sz,CliTest.test_shortuuid_command_produces_uuidcCs*tddg�|jdd}|�|d�dS)Nr�$3b1f8b40-222c-4a6e-b77e-779d5a94e21crr�rr\rr]rrr�test_encode_command�szCliTest.test_encode_commandcCs*tddg�|jdd}|�|d�dS)Nrrrr_r`r]rrr�test_decode_command�szCliTest.test_decode_commandN)r5r6r7rr^rarbrrrrr[�s

r[�__main__)!�osrC�sys�unittest�collectionsrZ
unittest.mockrrrrZ
shortuuid.clirZshortuuid.mainrrr	r
rr
�path�insert�abspath�__file__ZTestCaserr8rHrTrZr[r5�mainrrrr�<module>s0/D)