ó
ÎYc           @@  sē   d  Z  d d l m Z d d l Z d d l m Z m Z m Z d d l m	 Z	 m
 Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d S(   s.    This is the Bokeh charts testing interface.

i    (   t   absolute_importN(   t	   ColorAttrt   DashAttrt
   MarkerAttr(   t   ChartDataSourcet   NumericalColumnsAssignerc         C@  sL   t  j |  j   } t | j  d k s- t  t | j  d k sH t  d S(   s:   Test creating chart data source from array-like list data.i   i   N(   R   t	   from_datat	   list_datat   lent   columnst   AssertionErrort   index(   t	   test_datat   ds(    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt	   test_list   s    c         C@  sL   t  j |  j   } t | j  d k s- t  t | j  d k sH t  d S(   s;   Test creating chart data source from array-like numpy data.i   i   N(   R   R   t
   array_dataR   R	   R
   R   (   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt
   test_array#   s    c         C@  sē   |  j  j   } t j |  } t | j  d k s9 t  t | j  d k sT t  t |  } t | j  d k s{ t  t | j  d k s t  | j |  j   sŪ t  d S(   s8   Test creating chart data source from existing dataframe.i   i   N(	   t   pd_datat   copyR   R   R   R	   R
   R   t   equals(   R   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   test_pandas*   s    c         C@  sL   t  j |  j  } t | j  d k s- t  t | j  d k sH t  d S(   s4   Test creating chart data source from dict of arrays.i   i   N(   R   R   t	   dict_dataR   R	   R
   R   (   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt	   test_dict:   s    c         C@  sL   t  j |  j  } t | j  d k s- t  t | j  d k sH t  d S(   s4   Test creating chart data source from array of dicts.i   i   N(   R   R   t   records_dataR   R	   R
   R   (   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   test_recordsA   s    c         C@  sþ   xũ t  t t f D]æ } i | d |  j d d d d d d d g  d 6} i | d |  j d d d d d d d g  d 6} t d |  j  } t | j |    } t |  d
 k s· t  t d |  j  } t | j |    } t |  d k s t  q Wd  S(   Nt   dfR	   t   cylt   attrnamet   testt   iterablet   redt   bluet   origini   i	   (   R   R    (	   R   R   R   t	   auto_dataR   t   listt   groupbyR   R
   (   R   t   clst   single_col_spect   multi_col_specR   t   groups(    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   test_groupbyH   s    c         C@  sl   t  j |  j   } y5 g  | j D]# } g  | D] } | | ^ q, ^ q Wn t k
 rg t j d  n Xd  S(   Ns8   Required dimension not correctly set by ChartDataSource.(   R   R   R   t   _required_dimst   KeyErrort   pytestt   fail(   R   R   t   req_dimst   dim(    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   test_derived_selections[   s
    5c         C@  s5   t  j d |  j  } | d d d g k s1 t  d S(   s9   List of lists for dimension results in column derivation.t   yt   at   bN(   R   R   R   R
   (   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   test_derived_cols_from_lists_kwc   s    c         C@  s8   t  j |  j d d } | d d d g k s4 t  d S(   s9   List of lists for dimension results in column derivation.t   dimsR0   t   xR1   R2   N(   R0   R5   (   R   R   R   R
   (   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   test_derived_cols_from_listsi   s    c         C@  s>   t  j |  j d d d t } | d d d g k s: t  d S(	   s(  Wide dataframe columns assigned to y dimension for the chart.

    This tests using the NumericalColumnsAssigner, which is used for charts
    that prefer behavior of expecting series-like data. Typically the x axis
    is used as an index, then the y axis will be assigned multiple columns.
    R4   R5   R0   t   column_assignert   col1t   col2N(   R5   R0   (   R   R   R   R   R
   (   R   R   (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt    test_custom_derived_cols_from_dfo   s    	(   t   __doc__t
   __future__R    R+   t   bkcharts.attributesR   R   R   t   bkcharts.data_sourceR   R   R   R   R   R   R   R(   R/   R3   R6   R:   (    (    (    s>   lib/python2.7/site-packages/bkcharts/tests/test_data_source.pyt   <module>   s   									