o
    ¯bÒ	  ã                   @   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                   @   sH   e Zd 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S )ÚProcessMonitorTapTestsz]
    Tests for L{twisted.runner.procmontap}'s option parsing and makeService
    method.
    c                 C   s   t  ¡ }|  t|jg ¡ dS )z>
        The command line arguments must be provided.
        N)ÚtapÚOptionsÚassertRaisesr   ÚparseOptions©ÚselfÚopt© r   úE/usr/lib/python3/dist-packages/twisted/runner/test/test_procmontap.pyÚtest_commandLineRequired   s   z/ProcessMonitorTapTests.test_commandLineRequiredc                 C   ó*   t  ¡ }| g d¢¡ |  |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   ó   z%ProcessMonitorTapTests.test_thresholdc                 C   r   )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   r   )zg
        The minrestartdelay option is recognised as a parameter and coerced to
        float.
        )z--minrestartdelayr   r   Úminrestartdelayr   Nr   r   r   r   r   Útest_minRestartDelay,   r   z+ProcessMonitorTapTests.test_minRestartDelayc                 C   r   )zg
        The maxrestartdelay option is recognised as a parameter and coerced to
        float.
        )z--maxrestartdelayr   r   Úmaxrestartdelayr   Nr   r   r   r   r   Útest_maxRestartDelay5   r   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   s>   t  ¡ }| g d¢¡ t  |¡}|  |t¡ |  d|j¡ dS )zP
        The command line gets added as a process to the ProcessMontor.
        )Úpingz-cÚ3z8.8.8.8zping -c 3 8.8.8.8N)r   r   r
   ÚmakeServiceÚassertIsInstancer   ÚassertInÚ	processes)r   r   Úsr   r   r   Útest_makeServiceI   s
   
z'ProcessMonitorTapTests.test_makeServiceN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r"   r*   r   r   r   r   r      s    			r   N)r.   Útwisted.python.usager   Útwisted.runnerr   r   Útwisted.runner.procmonr   Útwisted.trialr   ÚTestCaser   r   r   r   r   Ú<module>   s   