
    1g(
                         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	 Z G d
 de      Zy)    )partial)DaphneProcess)ASGIStaticFilesHandler)ImproperlyConfigured)connections)TransactionTestCase)modify_settingsget_default_applicationc                 .    t               }|  | |      }|S Nr
   )static_wrapperapplications     M/var/www/html/Beni/venv/lib/python3.12/site-packages/channels/testing/live.pymake_applicationr      s     )+K!$[1    c                   b     e Zd ZdZdZeZeZdZ	e
d        Ze
d        Z fdZ fdZd Z x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                 :    d| j                   d| j                  S )Nzhttp://:host_portselfs    r   live_server_urlz*ChannelsLiveServerTestCase.live_server_url"   s    !%DJJ77r   c                 :    d| j                   d| j                  S )Nzws://r   r   r   s    r   live_server_ws_urlz-ChannelsLiveServerTestCase.live_server_ws_url&   s    #yy$**55r   c                 \   t        j                         D ]  }| j                  |      st        d       t        t
        |           t        d| j                  i      | _	        | j                  j                          t        t        | j                  r| j                  nd       }| j                  | j                  |      | _        | j                   j#                          | j                   j$                  j'                          | j                   j(                  j*                  | _        y )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__s      r   r&   z%ChannelsLiveServerTestCase._pre_setup*   s    %//+J$$Z0*X  , 	($:<.=#TYY//
+ 	++224!262C2C4..
  $99$))_U""$""'')))..44
r   c                     | j                   j                          | j                   j                          | j                  j	                          t
        t        |           y r   )r+   	terminatejoinr'   disabler%   r   _post_teardown)r   r3   s    r   r8   z)ChannelsLiveServerTestCase._post_teardownA   sG    &&(!!#++335($>@r   c                 B    |j                   dk(  r|j                         S y)zD
        Check if DatabaseWrapper holds in memory database.
        sqliteN)vendoris_in_memory_db)r   r1   s     r   r$   z+ChannelsLiveServerTestCase._is_in_memory_dbG   s&     (--// )r   )__name__
__module____qualname____doc__r   r   r*   r   r   r)   propertyr   r   r&   r8   r$   __classcell__)r3   s   @r   r   r      sU     D)+NL8 8 6 65.A0r   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   <module>rL      s/     ( F 7 ! 5 - 470!4 70r   