B
    u9aI  ã               @   st   d dl Z d dlZd dlmZmZmZ edƒZd dlZdd„ ZG dd„ dej	ƒZ
G dd	„ d	ej	ƒZed
krpe ¡  dS )é    N)ÚTESTFNÚimport_moduleÚunlinkÚmsilibc              C   s&   t d } t | tjdddd¡}|| fS )Nz.msizPython TestsZproduct_codez1.0ZPSF)r   r   Úinit_databaseZschema)ÚpathÚdb© r	   ú!/usr/lib/python3.7/test_msilib.pyr   	   s    r   c               @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚMsiDatabaseTestCasec             C   s€   t ƒ \}}g }| d¡}| d ¡ x&| ¡ }|d kr6P | | d¡¡ q$W | ¡  | ¡  |  |dddddg¡ |  t	|¡ d S )Nz$SELECT Property, Value FROM Propertyé   ZProductNameZProductCodeZProductVersionZManufacturerZProductLanguage)
r   ZOpenViewZExecuteZFetchÚappendZ	GetStringÚCloseÚassertEqualÚ
addCleanupr   )Úselfr   Údb_pathZ
propertiesZviewÚrecordr	   r	   r
   Útest_view_fetch_returns_none   s     



z0MsiDatabaseTestCase.test_view_fetch_returns_nonec          	   C   s¼   t ƒ \}}z˜| d¡}| tj¡}|  |d¡ | tjd¡ | tj¡}|  |d¡ | tjd¡ | tj¡}|  |d¡ | tjd¡ | tj¡}|  |d¡ W d d }d }t |¡ X d S )	Néc   s   Installation DatabaseAç  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)	r   ÚGetSummaryInformationÚGetPropertyr   Z	PID_TITLEr   ZSetPropertyÚosr   )r   r   r   Zsum_infoÚtitler	   r	   r
   Ú&test_summaryinfo_getproperty_issue1104-   s"    

z:MsiDatabaseTestCase.test_summaryinfo_getproperty_issue1104c          	   C   s<   |   tj¡}t dtj¡ W d Q R X |  t|jƒd¡ d S )Nznon-existent.msizopen failed)ÚassertRaisesr   ÚMSIErrorÚOpenDatabaseZMSIDBOPEN_READONLYr   ÚstrÚ	exception)r   Úcmr	   r	   r
   Útest_database_open_failedD   s    z-MsiDatabaseTestCase.test_database_open_failedc          	   C   sJ   t j td¡}|  tj¡}t |tj¡ W d Q R X |  	t
|jƒd¡ d S )Nztest.msizcreate failed)r   r   Újoinr   r   r   r   r   ZMSIDBOPEN_CREATEr   r   r   )r   r   r    r	   r	   r
   Útest_database_create_failedI   s    z/MsiDatabaseTestCase.test_database_create_failedc             C   s>   t ƒ \}}| d¡}|  | tj¡¡ | ¡  |  t|¡ d S )Nr   )	r   r   ZassertIsNoner   r   ZPID_SECURITYr   r   r   )r   r   r   Zsummaryr	   r	   r
   Útest_get_property_vt_emptyO   s
    

z.MsiDatabaseTestCase.test_get_property_vt_emptyc          	   C   s\   t ƒ \}}|  |j¡ t |dddd¡}t d¡}t ||d tddd¡}| d |d d¡ d S )	Nr   ÚFeaturez	A featureÚPythonÚCABZ	TARGETDIRZ	SourceDirZkeyfile)	r   r   r   r   r%   r'   Z	Directoryr   Zstart_component)r   r   r   ZfeatureZcabÚdirr	   r	   r
   Ú&test_directory_start_component_keyfileV   s    

z:MsiDatabaseTestCase.test_directory_start_component_keyfileN)	Ú__name__Ú
__module__Ú__qualname__r   r   r!   r#   r$   r)   r	   r	   r	   r
   r      s   r   c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTest_make_idc             C   s^   |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ d S )NZshortZnochangerequiredzone.dotÚ_Úa)r   r   Úmake_id)r   r	   r	   r
   Útest_is_no_change_requiredh   s    z'Test_make_id.test_is_no_change_requiredc             C   s(   |   t d¡d¡ |   t d¡d¡ d S )Nz9.shortz_9.shortz.shortz_.short)r   r   r0   )r   r	   r	   r
   Útest_invalid_first_charv   s    z$Test_make_id.test_invalid_first_charc             C   s(   |   t d¡d¡ |   t d¡d¡ d S )Nu   .sÂ‚ortz_.s_ortu
   .sÂ‚o?*+rtz
_.s_o___rt)r   r   r0   )r   r	   r	   r
   Útest_invalid_any_char|   s    z"Test_make_id.test_invalid_any_charN)r*   r+   r,   r1   r2   r3   r	   r	   r	   r
   r-   `   s   r-   Ú__main__)r   ZunittestZtest.supportr   r   r   r   Zmsilib.schemar   ZTestCaser   r-   r*   Úmainr	   r	   r	   r
   Ú<module>   s   J#