
    Hohd9                        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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  ee	      Z! ee
      Z" ee      Z# ee      Z$ ee      Z% ee      Z& ee      Z' ee      Z( ee      Z) ee      Z* ee      Z+ ee      Z, ee      Z- ee      Z. ee      Z/ ee      Z0 ee      Z1 ee      Z2 ee      Z3 ee      Z4 ee      Z5 ee      Z6 ee      Z7 ee       Z8 G d dejr                        Z: e;ejx                  j{                  ejx                  j}                  e?      d             5 Z@ e j                  e@      ZBddd       d! ZC ej                  eB      D ]&  \  ZEZF eeFd"         eFd#<    eGe:d$eEz    eCeF             ( y# 1 sw Y   HxY w)%    N)user_agent_parser   )compat)parsezMozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3zMozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10zMozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1zMozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30zMozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=truezzMozilla/5.0 (PlayBook; U; RIM Tablet OS 2.0.1; en-US) AppleWebKit/535.8+ (KHTML, like Gecko) Version/7.2.0.1 Safari/535.8+zMozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166  Safari/535.19zfMozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)zMozilla/5.0 (BlackBerry; U; BlackBerry 9800; zh-TW) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.448 Mobile Safari/534.8+zdBlackBerry9700/5.0.0.862 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/331 UNTRUSTED/1.0 3gpp-gbazMozilla/5.0 (BlackBerry; U; BlackBerry 9930; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.241 Mobile Safari/534.11+zEMozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)zWOpera/9.80 (J2ME/MIDP; Opera Mini/9.80 (J2ME/22.478; U; en) Presto/2.5.25 Version/10.54z@Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)zGMozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)ztMozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2z?Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)zLMozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1zHMozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)zMozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/12.0.024; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.12344z>Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0zZMozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 Lightning/4.0.2z\Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; Microsoft Outlook 15.0.4420)zmMozilla/5.0 (X11; CrOS i686 0.12.433) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.77 Safari/534.30c                   B    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)UserAgentsTestc                 z   t        j                  t        d   d         }t        d   d   }| j                  |j                  j
                  |d   d          | j                  |j                  j                  t        |d   d         t        |d   d         f       | j                  |j                  j
                  |d   d          | j                  |j                  j                  t        |d   d         t        |d   d         f       | j                  |j                  j
                  |d   d          y )	Niphone	ua_string
user_agentfamilymajorminorosdevice)
r   ParsedevicesassertEqualbrowserr   versionintr   r   )selfua_dict	iphone_uas      m/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/user_agents/tests.py"test_user_agent_object_assignmentsz1UserAgentsTest.test_user_agent_object_assignments?   s+   #))'(*;K*HIH%l3	 	**11 .x8	:%%&w/0&w/02	
 	,,gdmH.EFLL  w'(#gdmG.D*EF	
 	))00 *84	6    c                    | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t
        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t         j                         | j                  t"        j                         | j                  t$        j                         | j                  t&        j                         | j                  t(        j                         | j                  t*        j                         y N)assertFalser   	is_tabletgalaxy_s3_uablackberry_torch_uablackberry_bold_uawindows_phone_uaie_uaie_touch_uamac_safari_uawindows_ie_uaubuntu_firefox_uaj2me_opera_uagoogle_bot_uanokia_n97_ua
assertTruewindows_rt_uaipad_uaplaybook_uakindle_fire_ua
nexus_7_uaandroid_firefox_aurora_uar   s    r   test_is_tablet_propertyz&UserAgentsTest.test_is_tablet_propertyW   sw   ,,-//0,667+556)334)../001001*445001001//0//0))*--.001
,,-2<<=r   c                    | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t
        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t         j                         | j                  t"        j                         | j                  t$        j                         | j                  t&        j                         | j                  t(        j                         | j                  t*        j                         y r   )r.   r   	is_mobiler"   r#   r$   r%   r+   r-   r    r/   r0   r1   r2   r3   r&   r'   r(   r)   r*   r,   r4   r5   s    r   test_is_mobile_propertyz&UserAgentsTest.test_is_mobile_propertyl   sq   	++,../+556*445(223//0../001**+../112--.)../001001*4450011;;<r   c                    | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t
        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t         j                         | j                  t"        j                         | j                  t$        j                         | j                  t&        j                         | j                  t(        j                         | j                  t*        j                         | j                  t,        j                         y r   )r.   r   is_touch_capabler"   r0   r1   r2   r3   r%   r'   blackberry_bold_touch_uar8   r#   r    r+   r&   r$   r(   r)   r*   r,   r-   r4   r5   s    r   test_is_touch_propertyz%UserAgentsTest.test_is_touch_property   sn   	223556001445778
334(99:4450::;+556778//0+<<=778778*;;<7786671BBCr   c                    | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t
        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t         j                         | j                  t"        j                         | j                  t$        j                         | j                  t&        j                         | j                  t(        j                         | j                  t*        j                         | j                  t,        j                         y r   )r    r   is_pcr"   r0   r1   r2   r3   r%   r<   r#   r$   r+   r,   r-   r.   r(   r)   r*   r'   r&   r4   chromebook_uar5   s    r   
test_is_pczUserAgentsTest.test_is_pc   s   )++,'**+--.))*)//01778,223+112,,-,,-++,++,++,)//0))*$2889++,r   c                    | j                  t        j                         | j                  t        j                         | j                  t
        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t         j                         | j                  t"        j                         | j                  t$        j                         | j                  t&        j                         | j                  t(        j                         | j                  t*        j                         y r   )r.   r,   is_botr    r   r"   r0   r1   r2   r3   r%   r<   r#   r$   r+   r(   r)   r*   r'   r&   r-   r4   r5   s    r   test_is_botzUserAgentsTest.test_is_bot   s~   ,,-))*,,-(++,../**+)0011889,334+223--.--.--.*112++,&,,-299:r   c                 "   | j                  t        j                         | j                  t        j                         | j	                  t
        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t        j                         | j	                  t         j                         | j	                  t"        j                         | j	                  t$        j                         | j	                  t&        j                         y r   )r.   thunderbird_uais_email_client
outlook_uar    r1   r2   r3   r%   r<   r#   r$   r+   r(   r)   r*   r'   r&   r-   r4   r5   s    r   test_is_email_clientz#UserAgentsTest.test_is_email_client   sX   667
223445778334)99:1AAB,<<=+;;<667667667*::;445../5562BBCr   c                    | j                  t        t              d       | j                  t        t              d       | j                  t        t              d       | j                  t        t
              d       | j                  t        t              d       | j                  t        t              d       | j                  t        t              d       | j                  t        t              d       | j                  t        t              d	       | j                  t        t              d
       | j                  t        t              d       | j                  t        t              d       | j                  t        t              d       | j                  t        t              d       | j                  t        t               d       | j                  t        t"              d       | j                  t        t$              d       | j                  t        t&              d       | j                  t        t(              d       | j                  t        t*              d       | j                  t        t,              d       y )N$iPhone / iOS 5.1 / Mobile Safari 5.1z$iPad / iOS 3.2 / Mobile Safari 4.0.4z,Samsung SCH-I800 / Android 2.2 / Android 2.2z0Samsung GT-I9300 / Android 4.0.4 / Android 4.0.4z'Kindle / Android / Amazon Silk 1.1.0-80zJBlackBerry Playbook / BlackBerry Tablet OS 2.0.1 / BlackBerry WebKit 2.0.1z/Asus Nexus 7 / Android 4.1.1 / Chrome 18.0.1025z4Samsung SGH-i917 / Windows Phone 7.5 / IE Mobile 9.0zPC / Windows RT / IE 10.0z?BlackBerry 9800 / BlackBerry OS 6.0.0 / BlackBerry WebKit 6.0.0z7BlackBerry 9700 / BlackBerry OS 5.0.0 / BlackBerry 9700z?BlackBerry 9930 / BlackBerry OS 7.0.0 / BlackBerry WebKit 7.0.0z/Generic Feature Phone / Other / Opera Mini 9.80zPC / Windows 8 / IE 10.0z,PC / Mac OS X 10.6.8 / WebKit Nightly 537.13zPC / Windows 7 / IE 9.0zPC / Ubuntu / Firefox 15.0.1zSpider / Other / Googlebot 2.1z4Nokia N97 / Symbian OS 9.4 / Nokia Browser 7.1.12344z2Generic Smartphone / Android / Firefox Mobile 27.0)r   strr   r0   
galaxy_tabr"   r2   r1   r3   r%   r/   r#   r$   r<   r+   r&   r'   r(   r)   r*   r,   r-   r4   r5   s    r   test_stringszUserAgentsTest.test_strings   s   Y)OPW'MNZ*XY\*,^_^,.WX[)+wxZ*[\-.0fg]+-HI013tu/02kl568yz]+-^_U%?@[)+EF]+-[\]+-FG./1OP]+-MN\*,bc679mnr   c                     	 t        t        d   d         }| j                  |d       | j                  t	        |t                      y # t
        $ r* t        t        d   d         }| j                  |d       Y y w xY w)Nr
   r   rK   )unicoder   r   r.   
isinstance	NameErrorrL   )r   unicode_ua_strs     r   test_unicode_stringsz#UserAgentsTest.test_unicode_strings   s|    
	E$WX%6|%DEN^DFOOJ~w?@ 	E !2<!@AN^CE	Es   AA	 	0A<;A<N)__name__
__module____qualname__r   r6   r9   r=   rA   rD   rI   rN   rT    r   r   r   r   =   s3    60>*=*D*-,;*D(o.Er   r   zdevices.jsonc                       fd}|S )Nc                 `    d}|D ]&  }| j                  t        d   |      |   |       ( y )N)rC   r8   r?   r!   r;   r   )msg)r   getattr)r   attrsattritemss      r   	test_funcztest_wrapper.<locals>.test_func   sF    ; 	KDl+T2E$KT  K	Kr   rX   )r_   r`   s   ` r   test_wrapperra      s    K r   r   r   test_)Hjsonr   unittest	ua_parserr    r   parsersr   iphone_ua_stringipad_ua_stringgalaxy_tab_ua_stringgalaxy_s3_ua_stringkindle_fire_ua_stringplaybook_ua_stringnexus_7_ua_stringwindows_phone_ua_stringblackberry_torch_ua_stringblackberry_bold_ua_stringblackberry_bold_touch_ua_stringwindows_rt_ua_stringj2me_opera_ua_stringie_ua_stringie_touch_ua_stringmac_safari_ua_stringwindows_ie_ua_stringubuntu_firefox_ua_stringgoogle_bot_ua_stringnokia_n97_ua_string android_firefox_aurora_ua_stringthunderbird_ua_stringoutlook_usa_stringchromebook_ua_stringr   r0   rM   r"   r2   r1   r3   r%   r/   r#   r$   r<   r+   r&   r'   r(   r)   r*   r,   r-   r4   rF   rH   r@   TestCaser   openpathjoindirname__file__floadr   ra   	iteritemsr   r_   setattrrX   r   r   <module>r      s    	  '   \  f `  d  y  R  Z  C  a  C  #h ^ p Q^  N X i a  ~ #c  t s  G "#	

'(
(),-&'$%
01 *+67 45  !@A *+l&'*+*+23 *+()!"BC ,-%&
*+zEX&& zEz 
"'',,rwwx0.
AB adiilG
 &V%%g. CMFEk 23E,NGf,l5.ABC! s   F99G