File: //usr/lib/python3/dist-packages/twisted/names/test/__pycache__/test_tap.cpython-38.pyc
U
W[a � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ dd lmZ dd
lmZ ddlmZ G dd
� d
e�ZdS )z!
Tests for L{twisted.names.tap}.
� )�ThreadedResolver)�Resolver)�PORT)�
ResolverChain)�SecondaryAuthorityService)�Options�_buildResolvers)�_PY3)�platform)�
UsageError)�SynchronousTestCasec @ s8 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� ZdS )
�OptionsTestszf
Tests for L{Options}, defining how command line arguments for the DNS server
are parsed.
c C sZ t � }| �t|jddg� | �t|jddg� | �t|jddg� | �t|jddg� dS )z�
If the value supplied for an I{--secondary} option does not provide a
server IP address, optional port number, and domain name,
L{Options.parseOptions} raises L{UsageError}.
�--secondary� �1.2.3.4z
1.2.3.4:helloz1.2.3.4:hello/example.comN)r ZassertRaisesr �parseOptions��self�options� r �=/usr/lib/python3/dist-packages/twisted/names/test/test_tap.py�test_malformedSecondary s* � � � �z$OptionsTests.test_malformedSecondaryc C s2 t � }|�ddg� | �dtfdgfg|j� dS )z�
An argument of the form C{"ip/domain"} is parsed by L{Options} for the
I{--secondary} option and added to its list of secondaries, using the
default DNS port number.
r z1.2.3.4/example.comr �example.comN)r r �assertEqualr �secondariesr r r r �test_secondary, s �zOptionsTests.test_secondaryc C s. t � }|�ddg� | �ddgfg|j� dS )z�
An argument of the form C{"ip:port/domain"} can be used to specify an
alternate port number for which to act as a secondary.
r �1.2.3.4:5353/example.com)r �� r N)r r r r r r r r �test_secondaryExplicitPort8 s
�z'OptionsTests.test_secondaryExplicitPortc C s� t � }|�ddddg� | �t|j�d� |jd }| �|jd t� | �|jd� | �|jd� |jd }| �|jd t� | �|jd � | �|jd
� dS )z�
After parsing I{--secondary} options, L{Options} constructs a
L{SecondaryAuthorityService} instance for each configured secondary.
r r z1.2.3.5:5354/example.com� r r r � z1.2.3.5i� N) r r r �lenZsvcs�assertIsInstancer ZprimaryZ_port)r r Z secondaryr r r �test_secondaryAuthorityServicesC s �
z,OptionsTests.test_secondaryAuthorityServicesc C s� t � }|�dddg� t|�\}}|D ],}t|t�r&|jd }t|t�r&|j�� q&t �
� dkr�ddlm} |j
D ]8}tr�| �|jjtj� n| �|jjtjj� |�� qr| �|d t� dS ) z�
Recursive DNS lookups, if enabled, should be a last-resort option.
Any other lookup method (cache, local lookup, etc.) should take
precedence over recursive lookups
z--hosts-filez hosts.txtz--recursive����posixr )�reactorN)r r r �
isinstancer Z resolversr Z
_parseCallZcancelr
ZgetTypeZtwisted.internetr&