File: //usr/lib/python3/dist-packages/twisted/names/test/__pycache__/test_tap.cpython-310.pyc
o
�b� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ dd lmZ dd
lmZ G dd� de�Zd
S )z!
Tests for L{twisted.names.tap}.
� )�ThreadedResolver)�Resolver)�PORT)�
ResolverChain)�SecondaryAuthorityService)�Options�_buildResolvers)�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 �assertRaisesr
�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_secondaryExplicitPort5 s z'OptionsTests.test_secondaryExplicitPortc C s� t � }|�g d�� | �t|j�d� |jd }| �|jd t� | �|jd� | �|jd� |jd }| �|jd t� | �|jd� | �|jd� d S )
z�
After parsing I{--secondary} options, L{Options} constructs a
L{SecondaryAuthorityService} instance for each configured secondary.
)r
r r
z1.2.3.5:5354/example.com� r r r � z1.2.3.5i� N) r r r �len�svcs�assertIsInstancer �primary�_port)r r � secondaryr r r �test_secondaryAuthorityServices>