U
    “öh»  ã                   @  sT   d Z ddlmZ ddlmZ ddlmZ ejZG dd„ dejƒZ	e
dkrPe ¡  dS )	z!Unittest for sheets_sanitize_url.é    )Úannotations)Úabsltest)Úsheets_sanitize_urlc                   @  s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚSheetsSanitizeURLTestc              	   C  s<   |   td¡ tdƒ W 5 Q R X tdƒ}|  dt|ƒ¡ dS )zThe URL must be https://.z1Scheme for Sheets url must be "https", got "http"zhttp://docs.google.comúhttps://docs.google.comN©ÚassertRaisesRegexÚ
ValueErrorÚsanitize_sheets_urlÚassertEqualÚstr©ÚselfÚurl© r   úY/tmp/pip-unpacked-wheel-doshhd5e/google/generativeai/notebook/sheets_sanitize_url_test.pyÚtest_scheme_must_be_https   s     ÿz/SheetsSanitizeURLTest.test_scheme_must_be_httpsc              	   C  s<   |   td¡ tdƒ W 5 Q R X tdƒ}|  dt|ƒ¡ dS )zDomain must be docs.google.com.zHDomain for Sheets url must be "docs.google.com", got "sheets.google.com"zhttps://sheets.google.comr   Nr   r   r   r   r   Ú#test_domain_must_be_docs_google_com&   s    ýz9SheetsSanitizeURLTest.test_domain_must_be_docs_google_comc              	   C  s<   |   td¡ tdƒ W 5 Q R X tdƒ}|  dt|ƒ¡ dS )zParams component must be empty.z+Params component must be empty, got "hello"zhttps://docs.google.com/;hellor   Nr   r   r   r   r   Ú#test_params_must_be_docs_google_com5   s     ÿz9SheetsSanitizeURLTest.test_params_must_be_docs_google_comc              	   C  s<   |   td¡ tdƒ W 5 Q R X tdƒ}|  dt|ƒ¡ dS )z.Path can only contain a limited character set.z5Invalid path for Sheets url, got "/abc/def/sheets.phpz*https://docs.google.com/abc/def/sheets.phpz'https://docs.google.com/abc/DEF/123/-_-Nr   r   r   r   r   Ú'test_path_must_be_limited_character_set@   s     ÿz=SheetsSanitizeURLTest.test_path_must_be_limited_character_setc              	   C  s<   |   td¡ tdƒ W 5 Q R X tdƒ}|  dt|ƒ¡ dS )z/Query can only contain a limited character set.z6Invalid query for Sheets url, got "a=b&key=sheets.php"z+https://docs.google.com/?a=b&key=sheets.phpz4https://docs.google.com/?k1=abc&k2=DEF&k3=123&k4=-_-Nr   r   r   r   r   Ú(test_query_must_be_limited_character_setK   s     ÿÿ ÿz>SheetsSanitizeURLTest.test_query_must_be_limited_character_setc              	   C  s<   |   td¡ tdƒ W 5 Q R X tdƒ}|  dt|ƒ¡ dS )z2Fragment can only contain a limited character set.z9Invalid fragment for Sheets url, got "a=b&key=sheets.php"z+https://docs.google.com/#a=b&key=sheets.phpz4https://docs.google.com/#k1=abc&k2=DEF&k3=123&k4=-_-Nr   r   r   r   r   Ú+test_fragment_must_be_limited_character_setZ   s     ÿÿ ÿzASheetsSanitizeURLTest.test_fragment_must_be_limited_character_setN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r   r      s   r   Ú__main__N)Ú__doc__Ú
__future__r   Zabsl.testingr   Zgoogle.generativeai.notebookr   r
   ZTestCaser   r   Úmainr   r   r   r   Ú<module>   s   Q