File: //lib/python3/dist-packages/launchpadlib/tests/__pycache__/test_launchpad.cpython-310.pyc
o
    ;��a��  �                   @   s�  d Z eZddlmZ ddlZddlZddlZddlZddl	Z	ddl
Z
zddlmZ W n e
y9   ddlmZ Y nw ddlZddlmZ ddlmZmZ ddlmZ ddlZddlmZ dd	lmZ dd
lmZmZmZmZmZm Z m!Z! ddlm"Z" dZ#G d
d� de
j$�Z%G dd� de
j$�Z&G dd� de
j$�Z'G dd� de
j$�Z(G dd� de
j$�Z)G dd� de
j$�Z*G dd� de
j$�Z+G dd� de+�Z,G dd� de+�Z-G dd � d e
j$�Z.G d!d"� d"e
j$�Z/d#d$� Z0dS )%zTests for the Launchpad class.�    )�contextmanagerN)�patch)�ServiceRoot)�AccessToken�Credentials)�uris)�	Launchpad)�UnencryptedFileCredentialStore)�assert_keyring_not_imported�BadSaveKeyring�fake_keyring�FauxSocketModule�InMemoryKeyring�NoNetworkAuthorizationEngine�NoNetworkLaunchpad)�KeyringCredentialStore�http://api.example.com/c                   @   �   e Zd ZdZdd� ZdS )�TestResourceTypeClassesz<launchpadlib must know about restfulclient's resource types.c                 C   s*   t j�� D ]
\}}| �tj| |� qd S �N)r   �RESOURCE_TYPE_CLASSES�items�assertEqualr   )�self�name�cls� r   �C/usr/lib/python3/dist-packages/launchpadlib/tests/test_launchpad.py�test_resource_typesB   s   �z+TestResourceTypeClasses.test_resource_typesN)�__name__�
__module__�__qualname__�__doc__r   r   r   r   r   r   ?   s    r   c                   @   sl   e Zd ZdZdd� Zedd� �Zdd� Zdd	� Zd
d� Z	dd
� Z
dd� Zdd� Zdd� Z
dd� Zdd� ZdS )�TestNameLookupsz0Test the utility functions in the 'uris' module.c                 C   s   t g d��| _d S )N)�
production�	qastaging�staging�dogfood�dev�test_dev�edge)�sorted�aliases�r   r   r   r   �setUpL   s   
�zTestNameLookups.setUpc                 c   s|   � t jdd��-}t �d� d V  | �t|�d� |\}| �t|jt�� | �	dt
|�� W d   � d S 1 s7w   Y  d S )NT��record�always�   zno longer exists)�warnings�catch_warnings�simplefilterr   �len�
assertTrue�
issubclass�category�DeprecationWarning�assertIn�str)r   �caught�warningr   r   r   �edge_deprecation_errorY   s   �
"�z&TestNameLookups.edge_deprecation_errorc                 C   s4   | � ttj�� �| j� | � ttj�� �| j� d S r   )r   r+   r   �
service_roots�keysr,   �	web_rootsr-   r   r   r   �test_short_namesf   s   z TestNameLookups.test_short_namesc                 C   �F   | � � � | �t�d�t�d�� W d   � d S 1 sw   Y  d S �Nr*   r$   �r?   r   r   �lookup_service_rootr-   r   r   r   �$test_edge_service_root_is_productionk   �   
�"�z4TestNameLookups.test_edge_service_root_is_productionc                 C   rD   rE   �r?   r   r   �lookup_web_rootr-   r   r   r   � test_edge_web_root_is_productiont   rI   z0TestNameLookups.test_edge_web_root_is_productionc                 C   �H   | � � � | �t�tj�t�d�� W d   � d S 1 sw   Y  d S �Nr$   �r?   r   r   rG   �EDGE_SERVICE_ROOTr-   r   r   r   �-test_edge_service_root_url_becomes_production}   �   
�"�z=TestNameLookups.test_edge_service_root_url_becomes_productionc                 C   rM   rN   )r?   r   r   rK   �
EDGE_WEB_ROOTr-   r   r   r   �)test_edge_web_root_url_becomes_production�   rR   z9TestNameLookups.test_edge_web_root_url_becomes_productionc                 C   rM   rN   rO   r-   r   r   r   �/test_top_level_edge_constant_becomes_production�   rR   z?TestNameLookups.test_top_level_edge_constant_becomes_productionc                 C   rD   )Nzhttps://api.edge.launchpad.net/r$   rF   r-   r   r   r   �5test_edge_server_equivalent_string_becomes_production�   �   
�"�zETestNameLookups.test_edge_server_equivalent_string_becomes_productionc                 C   rD   )Nzhttps://edge.launchpad.net/r$   rJ   r-   r   r   r   �9test_edge_web_server_equivalent_string_becomes_production�   rW   zITestNameLookups.test_edge_web_server_equivalent_string_becomes_productionc                 C   s�   | � � � | jD ]}| �t�|�tj| � qW d  � n1 s!w   Y  | � � � | jD ]}| �t�|�tj| � q.W d  � n1 sGw   Y  d}| �t�|�|� | �t�|�|� d}| �t	tj|� | �t	tj|� dS )z=Ensure that short service names turn into long service names.Nzhttp://some-other-server.comz	not-a-url)
r?   r,   r   r   rG   r@   rK   rB   �assertRaises�
ValueError)r   �alias�
other_root�	not_a_urlr   r   r   �test_lookups�   s(   
���
���zTestNameLookups.test_lookupsN)r   r    r!   r"