ó
€ Hc           @   s$  d  d l  Z  d  d l Z d  d l m Z m Z m Z d e  j f d „  ƒ  YZ y d  d l	 Z	 WnÀ y– y2 d  d l
 Z
 e
 j d ƒ d d k r— e ‚ n  Wn] d  d l m Z m Z e d d	 g d
 e d e ƒZ e j ƒ  e j d k rø e ‚ qø n XWq e j d ƒ e ` e ` q Xn Xd S(   iÿÿÿÿN(   t   shellt   configt   loggert   XsltFilterTestsc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sŒ   t  j d ƒ d } t | ƒ j ƒ  } t j t  j ƒ  d | d d ƒ} t j j	 j
 | ƒ } | j d ƒ d j d ƒ } |  j d | ƒ d  S(	   Ns   tests/data/filter/translate.inis"   tests/data/filter/category-one.xmli    t   modet   filtert   categoryt   termt   OnE(   R   t   loadt   opent   readR    t   runt   filterst   xmlt   domt   minidomt   parseStringt   getElementsByTagNamet   getAttributet   assertEqual(   t   selft   testfilet   inputt   outputR   t   catterm(    (    sG   /home/sa3ruby/intertwingly.net/code/venus-bzr/tests/test_filter_xslt.pyt   test_xslt_filter   s    "c         C   s¤   d } d } t  j | t | ƒ j ƒ  d d ƒ} |  j | j d ƒ d k ƒ |  j | j d ƒ d k ƒ |  j | j d ƒ d k ƒ |  j | j d	 ƒ d k ƒ d  S(
   Ns   tests/data/filter/index.htmls   addsearch.xsltR   R   s   <h2>Search</h2>i    s   <form><input name="q"/></form>s@    href="http://planet.intertwingly.net/opensearchdescription.xml"s	   </script>(   R    R   R
   R   t
   assertTruet   find(   R   R   R   R   (    (    sG   /home/sa3ruby/intertwingly.net/code/venus-bzr/tests/test_filter_xslt.pyt   test_addsearch_filter   s    $(   t   __name__t
   __module__R   R   (    (    (    sG   /home/sa3ruby/intertwingly.net/code/venus-bzr/tests/test_filter_xslt.pyR      s   	
s   xsltproc --versioni    (   t   Popent   PIPEt   xsltprocs	   --versiont   stdoutt   stderrs3   libxslt is not available => can't test xslt filters(   t   unittestt   xml.dom.minidomR   t   planetR    R   R   t   TestCaseR   t   libxsltt   commandst   getstatusoutputt   ImportErrort
   subprocessR    R!   R"   t   communicatet
   returncodet   warnR   R   (    (    (    sG   /home/sa3ruby/intertwingly.net/code/venus-bzr/tests/test_filter_xslt.pyt   <module>   s(   
 