U
    wÁ	dd9  ã                	   @   sä  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ƒZ0eeƒZ1eeƒZ2eeƒZ3eeƒZ4eeƒZ5eeƒZ6eeƒZ7ee ƒZ8G dd„ dej9ƒZ:e;ej< =ej< >e?¡d ¡ƒZ@e  Ae@¡ZBW 5 Q R X d!d"„ ZCe DeB¡D ].\ZEZFeeFd# ƒeFd$< eGe:d%eE eCeFƒƒ q°dS )&é    N)Úuser_agent_parseré   )Úcompat)Úparsez†Mozilla/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.3z’Mozilla/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.10z†Mozilla/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.1z‹Mozilla/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.30zžMozilla/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+zƒMozilla/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-gbazƒMozilla/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)z¥Mozilla/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                   @   sT   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚUserAgentsTestc                 C   sÂ   t  td d ¡}td d }|  |jj|d d ¡ |  |jjt|d d ƒt|d d ƒf¡ |  |jj|d d ¡ |  |jjt|d d ƒt|d d ƒf¡ |  |j	j|d d ¡ d S )	NÚiphoneÚ	ua_stringÚ
user_agentÚfamilyÚmajorÚminorÚosÚdevice)
r   ÚParseÚdevicesÚassertEqualZbrowserr
   ÚversionÚintr   r   )ÚselfZua_dictÚ	iphone_ua© r   ú5/tmp/pip-unpacked-wheel-e11r830a/user_agents/tests.pyÚ"test_user_agent_object_assignments?   s&    

ÿÿþþ

ÿz1UserAgentsTest.test_user_agent_object_assignmentsc                 C   sè   |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   t	j¡ |   t
j¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |   tj¡ d S ©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   r   r   r   Útest_is_tablet_propertyW   s&    z&UserAgentsTest.test_is_tablet_propertyc                 C   sè   |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |  	t
j¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |  	tj¡ |   tj¡ d S r   )r(   r   Ú	is_mobiler   r   r   r   r%   r'   r   r)   r*   r+   r,   r-   r    r!   r"   r#   r$   r&   r.   r/   r   r   r   Útest_is_mobile_propertyl   s&    z&UserAgentsTest.test_is_mobile_propertyc                 C   sè   |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   t	j¡ |   t
j¡ |   tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |   tj¡ d S r   )r(   r   Úis_touch_capabler   r*   r+   r,   r-   r   r!   Úblackberry_bold_touch_uar1   r   r   r%   r    r   r"   r#   r$   r&   r'   r.   r/   r   r   r   Útest_is_touch_property   s&    z%UserAgentsTest.test_is_touch_propertyc                 C   sô   |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |   t	j¡ |   t
j¡ |   tj¡ |   tj¡ |   tj¡ |   tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |   tj¡ |  tj¡ d S r   )r   r   Úis_pcr   r*   r+   r,   r-   r   r4   r   r   r%   r&   r'   r(   r"   r#   r$   r!   r    r.   Úchromebook_uar/   r   r   r   Ú
test_is_pc–   s(    zUserAgentsTest.test_is_pcc                 C   sè   |   tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  t	j¡ |  t
j¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ d S r   )r(   r&   Úis_botr   r   r   r*   r+   r,   r-   r   r4   r   r   r%   r"   r#   r$   r!   r    r'   r.   r/   r   r   r   Útest_is_bot¬   s&    zUserAgentsTest.test_is_botc                 C   sÐ   |   tj¡ |   tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  t	j¡ |  t
j¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ |  tj¡ d S r   )r(   Úthunderbird_uaZis_email_clientÚ
outlook_uar   r+   r,   r-   r   r4   r   r   r%   r"   r#   r$   r!   r    r'   r.   r/   r   r   r   Útest_is_email_clientÁ   s"    z#UserAgentsTest.test_is_email_clientc                 C   sT  |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   tt	ƒd¡ |   tt
ƒd	¡ |   ttƒd
¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ |   ttƒd¡ d S )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   r*   Ú
galaxy_tabr   r,   r+   r-   r   r)   r   r   r4   r%   r    r!   r"   r#   r$   r&   r'   r.   r/   r   r   r   Útest_stringsÕ   s*    zUserAgentsTest.test_stringsc                 C   sf   z0t td d ƒ}|  |d¡ |  t|t ƒ¡ W n0 tk
r`   ttd d ƒ}|  |d¡ Y nX d S )Nr   r	   r>   )Úunicoder   r   r(   Ú
isinstanceÚ	NameErrorr?   )r   Zunicode_ua_strr   r   r   Útest_unicode_stringsì   s    ÿÿz#UserAgentsTest.test_unicode_stringsN)Ú__name__Ú
__module__Ú__qualname__r   r0   r2   r5   r8   r:   r=   rA   rE   r   r   r   r   r   =   s   r   zdevices.jsonc                    s   ‡ fdd„}|S )Nc                    s0   d}|D ]"}| j tˆ d |ƒˆ | |d qd S )N)r9   r1   r6   r   r3   r	   )Úmsg)r   Úgetattr)r   ÚattrsÚattr©Úitemsr   r   Ú	test_funcÿ   s      ÿztest_wrapper.<locals>.test_funcr   )rN   rO   r   rM   r   Útest_wrapperþ   s    	rP   r   r	   Ztest_)HÚjsonr   ZunittestZ	ua_parserr   Ú r   Úparsersr   Ziphone_ua_stringZipad_ua_stringZgalaxy_tab_ua_stringZgalaxy_s3_ua_stringZkindle_fire_ua_stringZplaybook_ua_stringZnexus_7_ua_stringZwindows_phone_ua_stringZblackberry_torch_ua_stringZblackberry_bold_ua_stringZblackberry_bold_touch_ua_stringZwindows_rt_ua_stringZj2me_opera_ua_stringZie_ua_stringZie_touch_ua_stringZmac_safari_ua_stringZwindows_ie_ua_stringZubuntu_firefox_ua_stringZgoogle_bot_ua_stringZnokia_n97_ua_stringZ android_firefox_aurora_ua_stringZthunderbird_ua_stringZoutlook_usa_stringZchromebook_ua_stringr   r*   r@   r   r,   r+   r-   r   r)   r   r   r4   r%   r    r!   r"   r#   r$   r&   r'   r.   r;   r<   r7   ZTestCaser   ÚopenÚpathÚjoinÚdirnameÚ__file__ÚfÚloadr   rP   Ú	iteritemsr   rN   Úsetattrr   r   r   r   Ú<module>   sz    >