o
    #i                     @   sX   d dl mZ d dlmZmZ d dlmZ ddlmZ G dd deZ	G dd	 d	eZ
d
S )    )ImproperlyConfigured)hostpatterns)get_host_patterns   )HostsTestCasec                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
PatternsTestsc                 C   sP   t dtdddd}| t|d | t|d t | t|d d d S )N apiapi.urlsnamer   r   z><host api: regex='api' urlconf='api.urls' scheme='//' port=''>)r   r   assertEquallen
assertTrue
isinstancereprselfhost_patterns r   Z/var/www/GraceOrthoHospital/venv_grace/lib/python3.10/site-packages/tests/test_defaults.pytest_pattern
   s   zPatternsTests.test_patternc                 C   s2   t dd}| t|d | t|d t d S )Nr	   )r
   r   r
   r   r   )r   r   r   r   r   r   r   r   r   r   test_pattern_as_tuple   s
   z#PatternsTests.test_pattern_as_tuplec                 C   s$   t dddd}| ttd|| d S )Nr
   r   r   r	   )r   assertRaisesr   r   r   api_hostr   r   r   test_pattern_with_duplicate   s   z)PatternsTests.test_pattern_with_duplicatec                 C   sN   t dtdddd}| t|d | t|d t | |d jd d S )Nmysiter
   r   r   r   r   zmysite.api.urls)r   r   r   r   r   r   urlconfr   r   r   r   test_pattern_with_prefix    s   z&PatternsTests.test_pattern_with_prefixN)__name__
__module____qualname__r   r   r   r    r   r   r   r   r      s
    
r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )	HostTestsc                 C   s"   t dddd}| t|t  d S )Nr
   r   r   )r   r   r   r   r   r   r   	test_host+   s   zHostTests.test_hostc                 C   s"   t ddddd}| |jd d S )Nr
   r   z	spam.eggs)r   prefixzspam.eggs.api.urls)r   r   r   r   r   r   r   test_host_prefix/   s   zHostTests.test_host_prefixc                 C   s"   t ddddd}| |jt d S )Nr
   r   z(django_hosts.resolvers.get_host_patternsr   callback)r   r   r)   r   r   r   r   r   test_host_string_callback3      z#HostTests.test_host_string_callbackc                 C   s"   t dddtd}| |jt d S )Nr
   r   r(   )r   r   r   r)   r   r   r   r   test_host_callable_callback8   r+   z%HostTests.test_host_callable_callbackc                    st   t ddddd | td fdd t ddddd | td	 fd
d t ddddd | t fdd d S )Nr
   r   zwhatever.non_existentr(   z7Could not import 'whatever'. Error was: No module namedc                          j S Nr)   r   r   r   r   <lambda>B       z:HostTests.test_host_nonexistent_callback.<locals>.<lambda>zdjango_hosts.non_existentzOCould not import 'django_hosts.non_existent'. Callable does not exist in modulec                      r-   r.   r/   r   r0   r   r   r1   I   r2   ztests.broken_module.yeah_yeahc                      r-   r.   r/   r   r0   r   r   r1   M   r2   )r   assertRaisesMessager   r   )r   r   r0   r   test_host_nonexistent_callback=   s$   

z(HostTests.test_host_nonexistent_callbackN)r!   r"   r#   r%   r'   r*   r,   r4   r   r   r   r   r$   )   s    r$   N)django.core.exceptionsr   django_hosts.defaultsr   r   django_hosts.resolversr   baser   r   r$   r   r   r   r   <module>   s    !