Ñò
3Nc           @€  sZ  d  d k  l Z d  d k Z d  d k Z e i e i i e i i e i i e ƒ ƒ ƒ ƒ d Z	 d  d k
 Z
 e
 i d ƒ d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k l Z d  d k l Z l Z l Z d e i j Z d „  Z e i i e i i e ƒ ƒ Z d e i f d	 „  ƒ  YZ e d
 j o e i  ƒ  n d S(   iÿÿÿÿ(   t   with_statementNt   Bazki(   t   command(   t   customt   modelt   testings   -vc         C€  su   t  p |  i d ƒ n t i |  d t i d t i ƒ} | i ƒ  \ } } | i d j o t | i | ƒ ‚ n d  S(   Ns   -qt   stdoutt   stderri    (   t   verboset   appendt
   subprocesst   Popent   PIPEt   communicatet
   returncodet   EnvironmentError(   t   cmdt   pt   outt   err(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   run   s    !t   BazsvnWithBazbasec           B€  s  e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C€  s`   t  i | d t  i d t  i ƒ} | i ƒ  \ } } |  i | | i ƒ |  i | | j | ƒ d  S(   NR   R   (   R
   R   R   R   t   assertEqualsR   t
   assertTrue(   t   selfR   t   statust   messageR   R   R   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   expectRunGetsStatus!   s
    c      	   C€  s3  t  i ƒ  |  _ t i ƒ  t i i ƒ  t i ƒ  t i i	 ƒ  t i i
 ƒ  t i d d ƒ |  _ t i d d |  i g ƒ t  i t  i i t d ƒ t  i i |  i d d ƒ ƒ d d d	 d
 d d t  i i t d ƒ d |  i g } t | ƒ t i d d ƒ |  _ t d d d |  i |  i g ƒ t  i |  i ƒ d  S(   Nt   suffixs	   .testrepot   svnadmint   creates
   pre-committ   hookst   svnt   imports
   --usernamet   bazkis   -ms   Bootstrapping...t   dbs   file://s   .testcheckoutt   cos	   file://%s(   t   ost   getcwdt   cwdR   t   set_up_for_testsR   t   sessiont   begint   cleart   committ   closet   tempfilet   mkdtempt   repoR
   t
   check_callt   symlinkt   patht   joint   hereR   t   checkoutt   chdir(   R   t
   import_cmd(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   setUp(   s$    


 c         C€  s4   t  i |  i ƒ t  i |  i ƒ t i |  i ƒ d  S(   N(   t   shutilt   rmtreeR6   R0   R%   R7   R'   (   R   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   tearDownA   s    c         C€  sÔ   d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d d d g ƒ t i i d	 ƒ } |  i d
 t	 | d i
 d ƒ ƒ |  i d t	 | d i
 d ƒ ƒ |  i d | i i ƒ d  S(   Ns   Object/Test/UnitTest.yamlt   ws;   comment: |
  This was created in a unit test.
name: George
R    t   addt   cis   -ms	   unit testu   UnitTestu   Georgeu   names   utf-8u!   This was created in a unit test.
u   commentu   Test(   t   opent   __exit__t	   __enter__t   writeR   R   t   Elementt   getR   t   unicodet   valuet   parentt   ename(   R   R3   t   _[1]t   outft   e(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_add_childF   s    & 	c         C€  s‹   d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d d d g ƒ t i i d ƒ } |  i d	 t	 | d
 i
 d ƒ ƒ d  S(   Ns   Object/Test/Test.yamlt   as   name: Paul
R    R?   s   -ms	   unit testu   Testu   Paulu   names   utf-8(   R@   RA   RB   RC   R   R   RD   RE   R   RF   RG   (   R   R3   RJ   RK   RL   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_add_propvalU   s    &c         C€  s±   d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d d d g ƒ t i i d ƒ } |  i d	 | j ƒ |  i	 d
 t
 | d	 i d ƒ ƒ |  i d | j ƒ d  S(   Ns   Object/Test/MergeTest.yamlR=   sH   comment: This test edits the comment and removes the 'test' prop value.
R    R?   s   -ms	   unit testu	   MergeTestu   commentu>   This test edits the comment and removes the 'test' prop value.s   utf-8u   test(   R@   RA   RB   RC   R   R   RD   RE   R   R   RF   RG   t   assertFalse(   R   R3   RJ   RK   RL   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_remove_propval^   s    & c         C€  s¨   d } t  i | ƒ | d } t | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ |  i d d d d	 g d
 d ƒ |  i t	 i
 t	 i i d ƒ d  S(   Ns   Object/Test/UnitTests   /UnitTest.yamlR=   s;   comment: |
  This was created in a unit test.
name: George
R    R>   R?   s   -ms	   unit testi   s^   If UnitTest has no kids, it needs to be in the form UnitTest.yaml, not UnitTest/UnitTest.yaml!u   UnitTest(   R%   t   mkdirR@   RA   RB   RC   R   R   t   assertRaisesR   t   NoResultFoundRD   RE   (   R   t   dirpathR3   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt(   test_add_child_with_leaf_directory_failsi   s    
&c         C€  sO   d } t  d d | g ƒ t  d d d d g ƒ |  i t i t i i d ƒ d  S(   Ns   Object/Test/MergeTest.yamlR    t   rmR?   s   -ms	   unit testu	   MergeTest(   R   RS   R   RT   RD   RE   (   R   R3   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_remove_childw   s    c         C€  s¬   d } d } d } d } t  d d | g ƒ t  d d | | g ƒ t  d d | g ƒ t  d d d	 d
 g ƒ |  i d t i i d ƒ i i ƒ |  i t i t i i d ƒ d  S(   Ns   Object/User/Admin/Daemon.yamls   Object/User/Admin/Admin.yamls   Object/User/Admin.yamls   Object/User/Admin/R    RW   t   mvR?   s   -ms	   unit testt   Useru   Adminu   Daemon(	   R   R   R   RD   RE   RH   RI   RS   RT   (   R   R3   t   parent_fromt	   parent_tot
   parent_dir(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_remove_last_child}   s    "c         C€  s^   d } t  d d | g ƒ |  i d d d d g d d ƒ |  i d	 t i i d
 ƒ i i ƒ d  S(   Ns   Object/User/Admin/Daemon.yamlR    RW   R?   s   -ms	   unit testi   sR   If Admin has no kids, it needs to be in the form Admin.yaml, not Admin/Admin.yaml!u   Adminu   Daemon(   R   R   R   R   RD   RE   RH   RI   (   R   R3   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt<   test_remove_last_child_without_removing_leaf_directory_fails‰   s
    c         C€  s»   d } d } d } d } d } t  d d | | g ƒ t  d d | | g ƒ t  d d | g ƒ t  d d	 d
 d g ƒ |  i d t i i d ƒ i i ƒ |  i d t i i d ƒ i i ƒ d  S(   Ns   Object/User/Admins   Object/Test/Admins   Object/Users   Object/User/User.yamls   Object/User.yamlR    RY   RW   R?   s   -ms	   unit testt   Testu   Admint   Adminu   Daemon(   R   R   R   RD   RE   RH   RI   (   R   t	   path_fromt   path_toR]   R[   R\   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_move_subtree‘   s    "c         C€  sk   d } t  d d | g ƒ t  d d d d g ƒ |  i t i t i i d ƒ |  i t i t i i d ƒ d  S(	   Ns   Object/TestR    RW   R?   s   -ms	   unit testu   Testu   Sandbox(   R   RS   R   RT   RD   RE   (   R   R3   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_remove_subtreež   s
    c         C€  s¬   d } d } d } d } t  d d | g ƒ t  d d | | g ƒ t  d d | g ƒ t  d d d	 d
 g ƒ |  i t i t i i d ƒ |  i d t i i d ƒ i ƒ  ƒ d  S(   Ns   Object/User/Admins   Object/Users   Object/User/User.yamls   Object/User.yamlR    RW   RY   R?   s   -ms	   unit testu   Admini    u   User(   R   RS   R   RT   RD   RE   R   t   countDescendants(   R   R3   R]   R[   R\   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_remove_last_subtree¥   s    c         C€  s€   d } t  d d | g ƒ |  i d d d d g d d ƒ |  i d	 t i i d
 ƒ i i ƒ |  i d
 t i i d ƒ i i ƒ d  S(   Ns   Object/User/AdminR    RW   R?   s   -ms	   unit testi   sN   If User has no kids, it needs to be in the form User.yaml, not User/User.yaml!u   Useru   Adminu   Daemon(   R   R   R   R   RD   RE   RH   RI   (   R   R3   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt>   test_remove_last_subtree_without_removing_leaf_directory_fails±   s    "c   	      C€  s‘  d } t  i | ƒ d } t | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXd } t | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d | g ƒ t d d | g ƒ t d d	 d
 d g ƒ t i i	 d ƒ } |  i
 d t | d i d ƒ ƒ t i i	 d ƒ } |  i
 d t | d i d ƒ ƒ |  i
 d t | d i d ƒ ƒ |  i
 d | i i ƒ |  i
 | | i ƒ d  S(   Ns   Object/Test/UnitTest/s"   Object/Test/UnitTest/UnitTest.yamlR=   s;   comment: |
  This was created in a unit test.
name: George
s!   Object/Test/UnitTest/TestTwo.yamls6   comment: |
  Also created in a unit test.
name: Ringo
R    R>   R?   s   -ms	   unit testu   UnitTestu   Georgeu   names   utf-8u   TestTwou   Ringou!   This was created in a unit test.
u   commentu   Test(   R%   RR   R@   RA   RB   RC   R   R   RD   RE   R   RF   RG   RH   RI   (	   R   t   dirR3   RJ   RK   t   path2t   _[2]RL   t   e2(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_add_subtreeº   s,    &&  	c         C€  sÝ   d } d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d	 d
 d g ƒ t i i d ƒ } |  i d t	 | d i
 d ƒ ƒ d  S(   Ns   Object/Test/Test.yamls   Object/Test/existent.txtRN   s   name: !include existent.txt
R=   t   PaulR    R>   R?   s   -ms	   unit testu   Testu   Paulu   names   utf-8(   R@   RA   RB   RC   R   R   RD   RE   R   RF   RG   (   R   R3   t   includeRJ   RK   Rk   t   incfRL   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_add_includeÖ   s    &&c         C€  sb   d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QX|  i d d d d g d d	 ƒ d  S(
   Ns   Object/Test/Test.yamlRN   s   name: !include nonexistent.txt
R    R?   s   -ms	   unit testi   s'   Couldn't read include 'nonexistent.txt'(   R@   RA   RB   RC   R   (   R   R3   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_add_broken_include_failsã   s    &c         C€  s°   d } d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d d d	 g ƒ |  i d
 t i i d ƒ j ƒ |  i	 d t i i d ƒ j ƒ d  S(   Ns   Object/Test/IncludeTest.yamls   Object/Test/product.txtR=   s   comment: No include.R    RW   R?   s   -ms	   unit testu   commentu   IncludeTestu   product(
   R@   RA   RB   RC   R   R   R   RD   RE   RP   (   R   R3   Ro   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_remove_includeë   s    &c         C€  s   d } d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d d d g ƒ |  i d	 t i i d
 ƒ j ƒ |  i	 d t i i d
 ƒ j ƒ d  S(   Ns   Object/Test/IncludeTest.yamls   Object/Test/product.txtR=   s   comment: No include.R    R?   s   -ms	   unit testu   commentu   IncludeTestu   product(
   R@   RA   RB   RC   R   R   R   RD   RE   RP   (   R   R3   Ro   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt)   test_remove_include_without_removing_fileõ   s    &c         C€  sB   d } d } t  d d | g ƒ |  i d d d d g d d	 ƒ d  S(
   Ns   Object/Test/IncludeTest.yamls   Object/Test/product.txtR    RW   R?   s   -ms	   unit testi   s<   Couldn't read include 'product.txt' for IncludeTest.product!(   R   R   (   R   R3   Ro   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt/   test_remove_file_without_removing_include_failsþ   s
    c         C€  s‘   d } d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d d d g ƒ t i i d	 ƒ } |  i d t	 | d
 i
 d ƒ ƒ d  S(   Ns   Object/Test/IncludeTest.yamls   Object/Test/product.txtR=   t   42R    R?   s   -ms	   unit testu   IncludeTestu   products   utf-8(   R@   RA   RB   RC   R   R   RD   RE   R   RF   RG   (   R   R3   Ro   RJ   Rp   RL   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_change_include  s    &c         C€  s‘   d } d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d d d g ƒ t i i d	 ƒ } |  i d
 t	 | d i
 d ƒ ƒ d  S(   Ns   Object/Test/IncludeTest.yamls   Object/Test/product.txtR=   s!   comment: Now inline.
product: 17
R    R?   s   -ms	   unit testu   IncludeTestt   17u   products   utf-8(   R@   RA   RB   RC   R   R   RD   RE   R   RF   RG   (   R   R3   Ro   RJ   RK   RL   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_include_to_inline  s    &c         C€  sÝ   d } d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d d	 d
 g ƒ t i i d ƒ } |  i d t	 | d i
 d ƒ ƒ d  S(   Ns   Object/Test/MergeTest.yamls   Object/Test/existent.txtR=   s:   comment: Now with an include!
test: !include existent.txt
s   The banner should be Blue!R    R>   R?   s   -ms	   unit testu	   MergeTestu   The banner should be Blue!u   tests   utf-8(   R@   RA   RB   RC   R   R   RD   RE   R   RF   RG   (   R   R3   Ro   RJ   RK   Rk   Rp   RL   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_inline_to_include  s    &&	c         C€  s®   d } t  i | ƒ d } t | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d | g ƒ t d d d d	 g ƒ |  i t i	 t i
 i d
 ƒ d  S(   Ns   Not-Object/s   Not-Object/Whatever.yamlR=   s/   It shouldn't matter that this isn't valid yaml.R    R>   R?   s   -ms	   unit testu   Whatever(   R%   RR   R@   RA   RB   RC   R   RS   R   RT   RD   RE   (   R   Ri   R3   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_yaml_not_under_object)  s    &c         C€  sˆ   d } t  | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d d d g ƒ |  i t i t i i	 d	 ƒ d  S(
   Ns   Whatever.yamlR=   s/   It shouldn't matter that this isn't valid yaml.R    R>   R?   s   -ms	   unit testu   Whatever(
   R@   RA   RB   RC   R   RS   R   RT   RD   RE   (   R   R3   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_top_level_yaml4  s    &c         C€  s›   d } t  i | ƒ d } t | d ƒ i i ƒ  } z | ~ } | i d ƒ Wd  QXt d d | g ƒ t d d | g ƒ |  i d d d d	 g d
 d ƒ d  S(   Ns   Object/Test/Dir/s   Object/Test/Dir/Something.yamlR=   s   comment: Whatever.
R    R>   R?   s   -ms	   unit testi   s/   Parent 'Dir' for element 'Something' undefined!(   R%   RR   R@   RA   RB   RC   R   R   (   R   Ri   R3   RJ   RK   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt    test_overly_nested_element_fails<  s    &c         C€  sE   d } d } t  d d | | g ƒ |  i d d d d g d d	 ƒ d  S(
   Nt   Objectt   PizzaR    RY   R?   s   -ms	   unit testi   s"   You can't delete the root element.(   R   R   (   R   t   object_fromt	   object_to(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_moving_root_failsI  s
    c         C€  sg   d } d } d } d } t  d d | | g ƒ t  d d | | g ƒ |  i d d d d	 g d
 d ƒ d  S(   NR~   R   s   Pizza/Object.yamls   Pizza/Pizza.yamlR    RY   R?   s   -ms	   unit testi   s"   You can't delete the root element.(   R   R   (   R   R€   R   t   def_fromt   def_to(    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt'   test_moving_root_and_renaming_def_failsP  s    c         C€  s<   d } t  d d | g ƒ |  i d d d d g d d ƒ d  S(	   NR~   R    RW   R?   s   -ms	   unit testi   s"   You can't delete the root element.(   R   R   (   R   R3   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_deleting_root_dir_failsZ  s    c         C€  s<   d } t  d d | g ƒ |  i d d d d g d d ƒ d  S(	   Ns   Object/Object.yamlR    RW   R?   s   -ms	   unit testi   s"   You can't delete the root element.(   R   R   (   R   R3   (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   test_deleting_root_def_fails`  s    (    t   __name__t
   __module__R   R9   R<   RM   RO   RQ   RV   RX   R^   R_   Rd   Re   Rg   Rh   Rm   Rq   Rr   Rs   Rt   Ru   Rw   Ry   Rz   R{   R|   R}   R‚   R…   R†   R‡   (    (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyR      s<   																				
												
	t   __main__(!   t
   __future__R    t   siteR%   t
   addsitedirR3   t   dirnamet   realpatht   __file__t   __requires__t   pkg_resourcest   requiret   unittestt   warningsR
   R:   t   sysR.   t   paste.scriptR   t   bazbaseR   R   R   t   argvR   R   t   abspathR5   t   TestCaseR   Rˆ   t   main(    (    (    sH   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/test/with_bazbase.pyt   <module>   s"   1$	ÿ H