o
    ^                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlmZ ddl	m
Z
 dd	lmZ es8dd
lmZ dd Zdd Zdd ZG dd deZG dd deZG dd deZG dd deZdS )z'Define the base module for server test.    )absolute_import)division)print_function)unicode_literalsN)
using_pypy)InfluxDbInstance)InfluxDBClient)DataFrameClientc                 C   sT   t | jt| ddd| _td| jjdddd| _ts(td| jjdddd| _	d S d S )	NZinfluxdb_udp_enabledF)Zudp_enabled	localhostroot db)database)
r   Zinfluxdb_template_confgetattrinfluxd_instr   	http_portclir   r	   ZcliDFinst r   B/usr/lib/python3/dist-packages/influxdb/tests/server_tests/base.py_setup_influxdb_server   s$   
r   c                 C   s   t d| jjddddd| _d S )Nr
   r   r   r   T)r   gzip)r   r   r   r   r   r   r   r   _setup_gzip_client'   s   r   c                 C   s   t  dk}| jj|d d S )N)NNN)remove_tree)sysexc_infor   close)r   r   r   r   r   _teardown_influxdb_server0   s   r   c                   @   (   e Zd ZdZedd Zedd ZdS )SingleTestCaseWithServerMixinzDefine the single testcase with server mixin.

    A mixin for unittest.TestCase to start an influxdb server instance
    in a temporary directory **for each test function/case**
    c                 C      t |  dS )z8Set up an instance of the SingleTestCaseWithServerMixin.Nr   clsr   r   r   setUp?      z#SingleTestCaseWithServerMixin.setUpc                 C   r!   z;Tear down an instance of the SingleTestCaseWithServerMixin.Nr   r#   r   r   r   tearDownD   r&   z&SingleTestCaseWithServerMixin.tearDownN__name__
__module____qualname____doc__classmethodr%   r)   r   r   r   r   r    5   s    	
r    c                   @   s8   e Zd ZdZedd Zdd Zedd Zdd	 Zd
S )ManyTestCasesWithServerMixinzDefine the many testcase with server mixin.

    Same as the SingleTestCaseWithServerMixin but this module creates
    a single instance for the whole class. Also pre-creates a fresh
    database: 'db'.
    c                 C   r!   )7Set up an instance of the ManyTestCasesWithServerMixin.Nr"   r#   r   r   r   
setUpClassT   r&   z'ManyTestCasesWithServerMixin.setUpClassc                 C      | j d dS )r1   r   N)r   Zcreate_databaseselfr   r   r   r%   Y      z"ManyTestCasesWithServerMixin.setUpc                 C   r!   )8Deconstruct an instance of ManyTestCasesWithServerMixin.Nr(   r#   r   r   r   tearDownClass]   r&   z*ManyTestCasesWithServerMixin.tearDownClassc                 C   r3   )r7   r   N)r   Zdrop_databaser4   r   r   r   r)   b   r6   z%ManyTestCasesWithServerMixin.tearDownN)	r+   r,   r-   r.   r/   r2   r%   r8   r)   r   r   r   r   r0   J   s    	

r0   c                   @   r   )!SingleTestCaseWithServerGzipMixinzDefine the single testcase with server with gzip client mixin.

    Same as the SingleTestCaseWithServerGzipMixin but the InfluxDBClient has
    gzip=True
    c                 C      t |  t|  dS )z<Set up an instance of the SingleTestCaseWithServerGzipMixin.Nr   r   r#   r   r   r   r%   n      z'SingleTestCaseWithServerGzipMixin.setUpc                 C   r!   r'   r(   r#   r   r   r   r)   t   r&   z*SingleTestCaseWithServerGzipMixin.tearDownNr*   r   r   r   r   r9   g       
r9   c                   @   r   ) ManyTestCasesWithServerGzipMixinzDefine the many testcase with server with gzip client mixin.

    Same as the ManyTestCasesWithServerMixin but the InfluxDBClient has
    gzip=True.
    c                 C   r:   )z;Set up an instance of the ManyTestCasesWithServerGzipMixin.Nr;   r#   r   r   r   r2      r<   z+ManyTestCasesWithServerGzipMixin.setUpClassc                 C   r!   r'   r(   r#   r   r   r   r)      r&   z)ManyTestCasesWithServerGzipMixin.tearDownN)r+   r,   r-   r.   r/   r2   r)   r   r   r   r   r>   z   r=   r>   )r.   Z
__future__r   r   r   r   r   Zinfluxdb.testsr   Z-influxdb.tests.server_tests.influxdb_instancer   Zinfluxdb.clientr   Zinfluxdb.dataframe_clientr	   r   r   r   objectr    r0   r9   r>   r   r   r   r   <module>   s$   	