o
    >h(
                     @   s|   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d	d
 ZG dd deZdS )    )partial)DaphneProcess)ASGIStaticFilesHandler)ImproperlyConfigured)connections)TransactionTestCase)modify_settingsget_default_applicationc                 C   s   t  }| d ur| |}|S Nr	   )static_wrapperapplication r   u/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/channels/testing/live.pymake_application   s   r   c                       s\   e Zd ZdZdZeZeZdZ	e
dd Ze
dd Z fdd	Z fd
dZdd Z  ZS )ChannelsLiveServerTestCasez
    Does basically the same as TransactionTestCase but also launches a
    live Daphne server in a separate process, so
    that the tests may use another test framework, such as Selenium,
    instead of the built-in dummy client.
    	localhostTc                 C      d| j | jf S )Nzhttp://%s:%shost_portselfr   r   r   live_server_url"      z*ChannelsLiveServerTestCase.live_server_urlc                 C   r   )Nz
ws://%s:%sr   r   r   r   r   live_server_ws_url&   r   z-ChannelsLiveServerTestCase.live_server_ws_urlc                    s   t  D ]}| |rtdqtt|   td| jid| _	| j	
  tt| jr-| jnd d}| | j|| _| j  | jj  | jjj| _d S )NzBChannelLiveServerTestCase can not be used with in memory databasesappend)ALLOWED_HOSTS)r   )r   all_is_in_memory_dbr   superr   
_pre_setupr   r   _live_server_modified_settingsenabler   r   serve_staticr   ProtocolServerProcess_server_processstartreadywaitportvaluer   )r   
connectionget_application	__class__r   r   r!   *   s&   


z%ChannelsLiveServerTestCase._pre_setupc                    s0   | j   | j   | j  tt|   d S r   )r&   	terminatejoinr"   disabler    r   _post_teardownr   r.   r   r   r3   A   s   


z)ChannelsLiveServerTestCase._post_teardownc                 C   s   |j dkr	| S dS )zD
        Check if DatabaseWrapper holds in memory database.
        sqliteN)vendoris_in_memory_db)r   r,   r   r   r   r   G   s   
z+ChannelsLiveServerTestCase._is_in_memory_db)__name__
__module____qualname____doc__r   r   r%   r   r   r$   propertyr   r   r!   r3   r   __classcell__r   r   r.   r   r      s    

r   N)	functoolsr   daphne.testingr   #django.contrib.staticfiles.handlersr   django.core.exceptionsr   	django.dbr   django.test.testcasesr   django.test.utilsr   channels.routingr
   r   r   r   r   r   r   <module>   s    