U
    ˆj

  ã                   @   sJ   d Z ddlmZ ddlmZ ddlmZ ddlm	Z	 G dd„ de	j
ƒZdS )	z)
Tests for L{twisted.runner.procmontap}.
é    )Ú
UsageError)Ú
procmontap)ÚProcessMonitor)Úunittestc                   @   sr   e Zd ZdZddœdd„Zddœdd„Zddœdd	„Zddœd
d„Zddœdd„Zddœdd„Z	ddœdd„Z
dS )ÚProcessMonitorTapTestsz]
    Tests for L{twisted.runner.procmontap}'s option parsing and makeService
    method.
    N)Úreturnc                 C   s   t  ¡ }|  t|jg ¡ dS )z>
        The command line arguments must be provided.
        N)ÚtapÚOptionsÚassertRaisesr   ÚparseOptions©ÚselfÚopt© r   úG/tmp/pip-unpacked-wheel-j5h_c8_q/twisted/runner/test/test_procmontap.pyÚtest_commandLineRequired   s    z/ProcessMonitorTapTests.test_commandLineRequiredc                 C   s,   t  ¡ }| dddg¡ |  |d d¡ dS )za
        The threshold option is recognised as a parameter and coerced to
        float.
        z--thresholdú7.5ÚfooÚ	thresholdç      @N©r   r	   r   ÚassertEqualr   r   r   r   Útest_threshold   s    z%ProcessMonitorTapTests.test_thresholdc                 C   s,   t  ¡ }| dddg¡ |  |d d¡ dS )zX
        The killtime option is recognised as a parameter and coerced to float.
        z
--killtimer   r   Úkilltimer   Nr   r   r   r   r   Útest_killTime$   s    z$ProcessMonitorTapTests.test_killTimec                 C   s,   t  ¡ }| dddg¡ |  |d d¡ dS )zg
        The minrestartdelay option is recognised as a parameter and coerced to
        float.
        z--minrestartdelayr   r   Úminrestartdelayr   Nr   r   r   r   r   Útest_minRestartDelay,   s    z+ProcessMonitorTapTests.test_minRestartDelayc                 C   s,   t  ¡ }| dddg¡ |  |d d¡ dS )zg
        The maxrestartdelay option is recognised as a parameter and coerced to
        float.
        z--maxrestartdelayr   r   Úmaxrestartdelayr   Nr   r   r   r   r   Útest_maxRestartDelay5   s    z+ProcessMonitorTapTests.test_maxRestartDelayc                 C   sX   t  ¡ }| dg¡ |  |d d¡ |  |d d¡ |  |d d¡ |  |d d¡ d	S )
z8
        The parameters all have default values
        r   r   é   r   é   r   r   i  Nr   r   r   r   r   Útest_parameterDefaults>   s    z-ProcessMonitorTapTests.test_parameterDefaultsc                 C   sB   t  ¡ }| ddddg¡ t  |¡}|  |t¡ |  d|j¡ dS )zP
        The command line gets added as a process to the ProcessMontor.
        Zpingz-cÚ3z8.8.8.8zping -c 3 8.8.8.8N)r   r	   r   ZmakeServiceZassertIsInstancer   ZassertInZ	processes)r   r   Úsr   r   r   Útest_makeServiceI   s
    
z'ProcessMonitorTapTests.test_makeService)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r!   r$   r   r   r   r   r      s   			r   N)r(   Ztwisted.python.usager   Ztwisted.runnerr   r   Ztwisted.runner.procmonr   Ztwisted.trialr   ZTestCaser   r   r   r   r   Ú<module>   s
   