
    ce                         d dl Z d dlZd dlZd dlmZ d dlmZ  G d dej                        Z G d dej                        Z
 G d d	ej                        Zy)
    N)base)cfgc                       e Zd Zdg g fdZy)TestConfigOptsNc                 T    t         j                  j                  | |ddddd||d
      S )Ntestz1.0z%(prog)s FOO BARsomedesctepilogT)	argsprogversionusagedescriptionepilogdefault_config_filesdefault_config_dirsvalidate_default_values)r   
ConfigOpts__call__)selfr   r   r   s       E/usr/lib/python3/dist-packages/oslo_config/tests/test_get_location.pyr   zTestConfigOpts.__call__   s<    ~~&&$"!5 3$( ' 
* 
	*    )__name__
__module____qualname__r    r   r   r   r      s     r%'*r   r   c                       e Zd Zd Zd Zy)LocationTestCasec                     | j                  t        j                  j                  j                         | j                  t        j                  j
                  j                         y N)
assertTruer   	Locationsuseris_user_controlledcommand_liner   s    r   test_user_controlledz%LocationTestCase.test_user_controlled(   s:    **==>22EEFr   c                 6   | j                  t        j                  j                  j                         | j                  t        j                  j
                  j                         | j                  t        j                  j                  j                         y r    )assertFalser   r"   opt_defaultr$   set_defaultset_overrider&   s    r   test_not_user_controlledz)LocationTestCase.test_not_user_controlled,   s\    22EEF22EEF33FFGr   N)r   r   r   r'   r-   r   r   r   r   r   &   s    GHr   r   c                   `     e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Z xZS )GetLocationTestCasec                    t         t        |           d }| j                  |       dt        _        t               | _        t	        j                  dd      | _	        | j                  j                  | j                         t	        j                  dd      | _        | j                  j                  | j                         t	        j                  dd	      | _        | j                  j                  | j                  d
       y )Nc                      dt         _        y )NF)r   _show_caller_detailsr   r   r   _clearz)GetLocationTestCase.setUp.<locals>._clear7   s
    ',C$r   T
normal_optnormal_opt_defaultdefaultcli_optcli_opt_default	group_optgroup_opt_defaultgroup)r<   )superr/   setUp
addCleanupr   r2   r   confStrOptr4   register_optr8   register_cli_optr:   )r   r3   	__class__s     r   r>   zGetLocationTestCase.setUp4   s    !4.0	-#' "$	**(
 			t/zz%
 			""4<<0'
 			t~~W=r   c                     | j                  g        | j                   j                  d      }| j                  t        j                  j
                  |j                         | j                  d|j                         y Nr4   test_get_location.py	r@   get_locationassertEqualr   r"   r*   locationassertIndetailr   locs     r   test_opt_defaultz$GetLocationTestCase.test_opt_defaultM   sX    		"ii$$\2MM%%LL	
 	,cjj9r   c                 P   | j                   j                  d| j                                | j                  g        | j                   j                  d      }| j	                  t
        j                  j                  |j                         | j                  d|j                         y rF   )
r@   r+   idrI   rJ   r   r"   rK   rL   rM   rN   s     r   test_set_default_on_config_optz2GetLocationTestCase.test_set_default_on_config_optV   sr    		lDGGI6		"ii$$\2MM%%LL	
 	,cjj9r   c                 \   t        j                  | j                  g| j                                | j	                  g        | j                  j                  d      }| j                  t         j                  j                  |j                         | j                  d|j                         y )N)r4   r4   rG   )r   set_defaultsr4   rR   r@   rI   rJ   r"   r+   rK   rL   rM   rN   s     r   test_set_defaults_funcz*GetLocationTestCase.test_set_defaults_func`   su    $//*twwyA		"ii$$\2MM%%LL	
 	,cjj9r   c                 P   | j                   j                  d| j                                | j                  g        | j                   j                  d      }| j	                  t
        j                  j                  |j                         | j                  d|j                         y rF   )
r@   r,   rR   rI   rJ   r   r"   rK   rL   rM   rN   s     r   test_set_overridez%GetLocationTestCase.test_set_overridej   sr    		|TWWY7		"ii$$\2MM&&LL	
 	,cjj9r   c                    | j                  dd| j                               }| j                  d|ddg       | j                  j                  d      }| j	                  t
        j                  j                  |j                         y )NDEFAULTunknown_opt--config-filez	--cli_optblahr8   )	_write_opt_to_tmp_filerR   r@   rI   rJ   r   r"   r%   rK   r   filenamerO   s      r   test_user_cliz!GetLocationTestCase.test_user_clit   so    ..}dggi1		?H( 	)ii$$Y/MM&&LL	
r   c                 
   | j                  dd| j                               }| j                  d|g       | j                  j                  d      }| j	                  t
        j                  j                  |j                         y )NrZ   r[   r\   r8   )	r^   rR   r@   rI   rJ   r   r"   r*   rK   r_   s      r   test_default_cliz$GetLocationTestCase.test_default_cli   sf    ..}dggi1		?H-.ii$$Y/MM%%LL	
r   c                     t        j                         }t        j                  |dd      5 }|j	                  t        j                  d      j                  |||             d d d        |S # 1 sw Y   |S xY w)Nwzutf-8)encodingzB
            [{group}]
            {option} = {value}
            )r<   optionvalue)tempfilemktempioopenwritetextwrapdedentformat)r   r<   rg   rh   r`   fs         r   r^   z*GetLocationTestCase._write_opt_to_tmp_file   st    ??$WWXsW5 	GGHOO %    	 	 s   7A..A8c                 B   | j                  dd| j                               }| j                  d|g       | j                  j                  d      }| j	                  t
        j                  j                  |j                         | j	                  ||j                         y )NrZ   r8   r\   
r^   rR   r@   rI   rJ   r   r"   r#   rK   rM   r_   s      r   test_user_cli_opt_in_filez-GetLocationTestCase.test_user_cli_opt_in_file   s    ..y$'')-		?H-.ii$$Y/MMLL	
 	JJ	
r   c                 B   | j                  dd| j                               }| j                  d|g       | j                  j                  d      }| j	                  t
        j                  j                  |j                         | j	                  ||j                         y )NrZ   r4   r\   rs   r_   s      r   test_user_filez"GetLocationTestCase.test_user_file   s    ..|TWWY0		?H-.ii$$\2MMLL	
 	JJ	
r   c                     t        j                  dd      }t        j                  t         j                  j                  d      |_        | j                  | j                  j                  |             y )Nr4   r5   r6   zan alternative file)	r   rA   LocationInfor"   r*   _set_locationr)   r@   rB   )r   dupe_opts     r   test_duplicate_registrationz/GetLocationTestCase.test_duplicate_registration   s\     ::(
 "%!1!1MM%%!"
 	//9:r   c                     | j                  g        | j                   j                  dd      }| j                  t        j                  j
                  |j                         | j                  d|j                         y )Nr:   r<   rG   rH   rN   s     r   test_group_optz"GetLocationTestCase.test_group_opt   sZ    		"ii$$[':MM%%LL	
 	,cjj9r   )r   r   r   r>   rP   rS   rV   rX   ra   rc   r^   rt   rv   r{   r}   __classcell__)rD   s   @r   r/   r/   2   s?    >2::::	



;(:r   r/   )rk   ri   rn   oslotestr   oslo_configr   r   r   BaseTestCaser   r/   r   r   r   <module>r      sN    
    *S^^ * 	Ht(( 	H[:$++ [:r   