
    i)              	          d Z ddlZddlmc mZ ddlZddl	Z	ddl
Z
ddlZddlmZ ddlZe
j                  j!                  d e ee      j&                  j&                               ej(                  j+                  d ee      j&                  j&                  dz        Zg ZeZerej2                  ZeZesddd ej6                         v s ej8                  e      r ej:                  e      ndiz  Zej?                  e       er`d	d ej6                         v s ej8                  e      r ej:                  e      nd ej:                  e      d
z  Z ej?                  e         ejB                  ed      i z  Z"dde"iz  Z# e$ ejJ                  e#            dxZxZZej(                  jM                  e      Z'ej2                  jQ                  e'       d)dede)dedefdZ*d*dede)defdZ+ G d d      Z, G d d      Z- G d d      Z. G d d      Z/ G d d      Z0 G d d      Z1 G d d       Z2 G d! d"      Z3 G d# d$      Z4 G d% d&      Z5 G d' d(      Z6y)+uC   Tests for cleanup-workspace.py — TDD 방식. tmp_path 로 격리.    N)Pathcleanup_workspacezcleanup-workspace.pyz%(py2)spy2_specz#%(py6)s
{%(py6)s = %(py4)s.loader
})py4py6assert %(py9)spy9pathdayscontentreturnc                     | j                   j                  dd       | j                  |       |r2t        j                         |dz  z
  }t	        j
                  | ||f       | S NT)parentsexist_okQ )parentmkdir
write_texttimeosutime)r   r   r   tss       ;/home/jay/workspace/scripts/tests/test_cleanup_workspace.py_mkr      sS    KKdT2OOGYY[4%<'
Bx K    c                     | j                  dd       |r2t        j                         |dz  z
  }t        j                  | ||f       | S r   )r   r   r   r   )r   r   r   s      r   _mk_dirr      s@    JJtdJ+YY[4%<'
Bx Kr   c                   L    e Zd ZdeddfdZdeddfdZdeddfdZdeddfdZy)TestTmptmp_pathr   Nc                    t        |dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
z  }dd|iz  }t        t        j                  |            d x}x}}y )Ntmpold.txt   r   in)zY%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_tmp_candidates
}(%(py5)s)
}fcwr"   py0r   r   py5py7r	   r
   r   r+   find_tmp_candidates
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationselfr"   r*   @py_assert3@py_assert6@py_assert1@py_format8@py_format10s           r   test_old_is_candidatezTestTmp.test_old_is_candidate&   s    5 9,15**4*844q44444q4444444q444q444444B444B444*4444448444844444444444r   c                    t        |dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
z  }dd|iz  }t        t        j                  |            d x}x}}y )Nr$   znew.txt   r'   not inz]%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_tmp_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r0   r:   s           r   test_recent_not_candidatez!TestTmp.test_recent_not_candidate*   s    5 9,15..8.x88q88888q8888888q888q888888888888.888888x888x88888888888r   c                    t        |dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
z  }dd|iz  }t        t        j                  |            d x}x}}y )Nr$   z
border.txt   r'   rD   rF   r*   r+   r"   r,   r	   r
   r0   r:   s           r   test_exactly_7_not_candidatez$TestTmp.test_exactly_7_not_candidate.   s    5 </a8..8.x88q88888q8888888q888q888888888888.888888x888x88888888888r   c                 l   t         j                  } ||      }g }||k(  }|s
t        j                  d|fd||f      dt	        j
                         v st        j                  t               rt        j                  t               ndt        j                  |      dt	        j
                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}x}}y )N==)zY%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.find_tmp_candidates
}(%(py3)s)
} == %(py8)sr+   r"   )r-   r   py3r.   py8zassert %(py10)spy10)
r+   r1   r2   r3   r4   r5   r6   r7   r8   r9   )r;   r"   r>   @py_assert4@py_assert7r=   @py_format9@py_format11s           r   test_missing_dir_emptyzTestTmp.test_missing_dir_empty2   s    %%5%h/525/25555/2555555r555r555%555555h555h555/55525555555r   )__name__
__module____qualname__r   rA   rG   rJ   rU    r   r   r!   r!   %   sN    5d 5t 59$ 94 99T 9d 96t 6 6r   r!   c                   L    e Zd ZdeddfdZdeddfdZdeddfdZdeddfdZy)
TestEventsr"   r   Nc                    t        |dz  dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nmemoryeventst.done.clear   r'   r(   z\%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_events_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r   r+   find_events_candidatesr2   r3   r4   r5   r6   r7   r8   r9   r:   s           r   test_old_done_clearzTestEvents.test_old_done_clear9       8#h.?bI--7-h77q77777q7777777q777q777777B777B777-777777h777h77777777777r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   r^   zt.done.acked#   r'   r(   ra   r*   r+   r"   r,   r	   r
   rb   r:   s           r   test_old_done_ackedzTestEvents.test_old_done_acked=   re   r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   r^   r_   
   r'   rD   z`%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_events_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   rb   r:   s           r   rG   z$TestEvents.test_recent_not_candidateA   s    8#h.?bI11;1(;;q;;;;;q;;;;;;;q;;;q;;;;;;;;;;;;1;;;;;;(;;;(;;;;;;;;;;;r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   r^   zt.done.notified(   r'   rD   rk   r*   r+   r"   r,   r	   r
   rb   r:   s           r   test_other_suffix_ignoredz$TestEvents.test_other_suffix_ignoredE   s    8#h.1BBL11;1(;;q;;;;;q;;;;;;;q;;;q;;;;;;;;;;;;1;;;;;;(;;;(;;;;;;;;;;;r   )rV   rW   rX   r   rd   rh   rG   rn   rY   r   r   r[   r[   8   sN    8D 8T 88D 8T 8<$ <4 <<$ <4 <r   r[   c                   L    e Zd ZdeddfdZdeddfdZdeddfdZdeddfdZy)TestDispatchr"   r   Nc                    t        |dz  dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   taskszdispatch-001.md[   r'   r(   )z^%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_dispatch_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r   r+   find_dispatch_candidatesr2   r3   r4   r5   r6   r7   r8   r9   r:   s           r   test_old_dispatch_candidatez(TestDispatch.test_old_dispatch_candidateM   s    8#g-0AAK//9/99q99999q9999999q999q999999B999B999/99999999999999999999r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   rr   zdispatch-002.md   r'   rD   zb%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_dispatch_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   rt   r:   s           r   "test_recent_dispatch_not_candidatez/TestDispatch.test_recent_dispatch_not_candidateQ       8#g-0AAK33=3H==q=====q=======q===q============3======H===H===========r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   rr   ztask-999.md   r'   rD   ry   r*   r+   r"   r,   r	   r
   rt   r:   s           r   test_task_md_never_candidatez)TestDispatch.test_task_md_never_candidateU   s    8#g-=CH33=3H==q=====q=======q===q============3======H===H===========r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   rr   zdispatch-003.mdZ   r'   rD   ry   r*   r+   r"   r,   r	   r
   rt   r:   s           r   test_exactly_90_not_candidatez*TestDispatch.test_exactly_90_not_candidateY   r{   r   )rV   rW   rX   r   rv   rz   r~   r   rY   r   r   rp   rp   L   sN    :D :T :>4 >D >>T >d >>d >t >r   rp   c                   <    e Zd ZdeddfdZdeddfdZdeddfdZy)TestLogsr"   r   Nc                    t        |dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
z  }dd|iz  }t        t        j                  |            d x}x}}y )Nlogszapp.log=   r'   r(   )zZ%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_logs_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r   r+   find_logs_candidatesr2   r3   r4   r5   r6   r7   r8   r9   r:   s           r   test_old_log_candidatezTestLogs.test_old_log_candidatea   s    6!I-B7++5+H55q55555q5555555q555q555555B555B555+555555H555H55555555555r   c                    t        |dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
z  }dd|iz  }t        t        j                  |            d x}x}}y )Nr   z
recent.log   r'   rD   z^%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_logs_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r   r:   s           r   test_recent_log_not_candidatez&TestLogs.test_recent_log_not_candidatee   s    6!L0q9//9/99q99999q9999999q999q999999999999/99999999999999999999r   c                    t        |dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
z  }dd|iz  }t        t        j                  |            d x}x}}y )Nr   zcleanup-2025-01-01.logd   r'   rD   r   r*   r+   r"   r,   r	   r
   r   r:   s           r   test_cleanup_log_excludedz"TestLogs.test_cleanup_log_excludedi   s    6!$<<3G//9/99q99999q9999999q999q999999999999/99999999999999999999r   )rV   rW   rX   r   r   r   r   rY   r   r   r   r   `   s;    6t 6 6:d :t ::$ :4 :r   r   c                   ,    e Zd ZdeddfdZdeddfdZy)TestBackupsr"   r   Nc                    t        |dz  dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   backupsz
old.tar.gzrs   r'   r(   )z]%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_backups_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r   r+   find_backups_candidatesr2   r3   r4   r5   r6   r7   r8   r9   r:   s           r   test_old_backup_candidatez%TestBackups.test_old_backup_candidateq   s    8#i/,>RH..8.x88q88888q8888888q888q888888B888B888.888888x888x88888888888r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr]   r   z
new.tar.gzrj   r'   rD   )za%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_backups_candidates
}(%(py5)s)
}r*   r+   r"   r,   r	   r
   r   r:   s           r    test_recent_backup_not_candidatez,TestBackups.test_recent_backup_not_candidateu   s    8#i/,>RH22<28<<q<<<<<q<<<<<<<q<<<q<<<<<<<<<<<<2<<<<<<8<<<8<<<<<<<<<<<r   )rV   rW   rX   r   r   r   rY   r   r   r   r   p   s(    9$ 94 9= =$ =r   r   c                   l    e Zd ZdedededededefdZdeddfd	Zdeddfd
Z	deddfdZ
deddfdZy)TestTeamTaskr"   teamtaskr   
has_reportr   c                     |dz  |z  |z  }t        |dz  |       t        j                         |dz  z
  }t        j                  |||f       |rt        |dz  dz  | dz         |S )Nteamszwork.mdr'   r   r]   reportsz-rpt.md)r   r   r   r   )r;   r"   r   r   r   r   task_dirr   s           r   _setupzTestTeamTask._setup}   sq    g%,t3Hy t,YY[4%<'
B8$8#i/TF'2BBCr   Nc                    | j                  |dddd      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Ndev7ztask-42r`   Tr   r   r(   )z_%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_team_task_candidates
}(%(py5)s)
}dr+   r"   r,   r	   r
   r   r+   find_team_task_candidatesr2   r3   r4   r5   r6   r7   r8   r9   r;   r"   r   r<   r=   r>   r?   r@   s           r   test_old_with_reportz!TestTeamTask.test_old_with_report   s    KK&)"KN00:0::q:::::q:::::::q:::q::::::B:::B:::0::::::::::::::::::::r   c                    | j                  |dddd      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr   ztask-43r`   Fr   rD   zc%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_team_task_candidates
}(%(py5)s)
}r   r+   r"   r,   r	   r
   r   r   s           r   test_old_without_reportz$TestTeamTask.test_old_without_report   s    KK&)"KO44>4X>>q>>>>>q>>>>>>>q>>>q>>>>>>>>>>>>4>>>>>>X>>>X>>>>>>>>>>>r   c                    | j                  |dddd      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Ndev3ztask-44rj   Tr   rD   r   r   r+   r"   r,   r	   r
   r   r   s           r   test_recent_with_reportz$TestTeamTask.test_recent_with_report   s    KK&)"KN44>4X>>q>>>>>q>>>>>>>q>>>q>>>>>>>>>>>>4>>>>>>X>>>X>>>>>>>>>>>r   c                    t        |dz  dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndd	t        j                         v st        j                  t              rt        j                  t              nd	t        j                  |      d
t        j                         v st        j                  |      rt        j                  |      nd
t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr   dev1sharedr   r'   rD   r   r   r+   r"   r,   r	   r
   )r   r+   r   r2   r3   r4   r5   r6   r7   r8   r9   r   s           r   test_non_task_dir_ignoredz&TestTeamTask.test_non_task_dir_ignored   s    Hw&/(:E44>4X>>q>>>>>q>>>>>>>q>>>q>>>>>>>>>>>>4>>>>>>X>>>X>>>>>>>>>>>r   )rV   rW   rX   r   strfloatboolr   r   r   r   r   rY   r   r   r   r   |   s    t 3 c (,15;T ;d ;? ? ?? ? ??$ ?4 ?r   r   c                   L    e Zd ZdeddfdZdeddfdZdeddfdZdeddfdZy)TestCokacDirr"   r   Nc                    |dz  dz  }t        |dz  dz  d      }t        j                  } ||      }||v }|s7t        j                  d|fd||f      d	t        j                         v st        j                  |      rt        j                  |      nd	d
t        j                         v st        j                  t              rt        j                  t              nd
t        j                  |      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )N	.cokacdir	workspacePROJfile.pdfr`   r'   r(   )z^%(py0)s in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_cokacdir_candidates
}(%(py5)s)
}r*   r+   wsr,   r	   r
   r   r+   find_cokacdir_candidatesr2   r3   r4   r5   r6   r7   r8   r9   	r;   r"   r   r*   r<   r=   r>   r?   r@   s	            r   test_old_upload_candidatez&TestCokacDir.test_old_upload_candidate   s    #k1Vj(r2//3/33q33333q3333333q333q333333B333B333/33333333333333333333r   c                    |dz  dz  }t        |dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      d	t        j                         v st        j                  |      rt        j                  |      nd	d
t        j                         v st        j                  t              rt        j                  t              nd
t        j                  |      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr   r   r   r   r   r'   rD   zb%(py0)s not in %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s.find_cokacdir_candidates
}(%(py5)s)
}r*   r+   r   r,   r	   r
   r   r   s	            r   rG   z&TestCokacDir.test_recent_not_candidate   s    #k1Vj(q13373B77q77777q7777777q777q7777777777773777777B777B77777777777r   c                    |dz  dz  }t        |dz  dz  d      }t        j                  } ||      }||v}|s7t        j                  d|fd||f      d	t        j                         v st        j                  |      rt        j                  |      nd	d
t        j                         v st        j                  t              rt        j                  t              nd
t        j                  |      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr   r   r   z
border.pdfrx   r'   rD   r   r*   r+   r   r,   r	   r
   r   r   s	            r   test_exactly_30_not_candidatez*TestCokacDir.test_exactly_30_not_candidate   s    #k1Vl*43373B77q77777q7777777q777q7777777777773777777B777B77777777777r   c           
         t         j                  }d}||z  }d}||z  } ||      }g }||k(  }	|	s2t        j                  d|	fd||f      dt	        j
                         v st        j                  t               rt        j                  t               ndt        j                  |      dt	        j
                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      t        j                  |      t        j                  |      dz  }
dd	|
iz  }t        t        j                  |            d x}x}x}x}x}x}x}	}y )
Nr   r   rL   )zy%(py11)s
{%(py11)s = %(py2)s
{%(py2)s = %(py0)s.find_cokacdir_candidates
}(((%(py3)s / %(py5)s) / %(py8)s))
} == %(py14)sr+   r"   )r-   r   rN   r.   rO   py11py14zassert %(py16)spy16)
r+   r   r2   r3   r4   r5   r6   r7   r8   r9   )r;   r"   r>   rQ   r=   rR   @py_assert9@py_assert10@py_assert13@py_assert12@py_format15@py_format17s               r   rU   z#TestCokacDir.test_missing_dir_empty   s    **VkV8k+AVKV+AK+OV*+OPVTVVPTVVVVVPTVVVVVVVrVVVrVVV*VVVVVV8VVV8VVVkVVVKVVVPVVVTVVVVVVVVVr   )rV   rW   rX   r   r   rG   r   rU   rY   r   r   r   r      sQ    4$ 44 4
8$ 84 8
8d 8t 8
Wt W Wr   r   c                   L    e Zd Zd	dZd	dZdeddfdZdeddfdZdeddfdZy)
TestProtectedr   Nc                    dD ]  }t         j                  }||v }|st        j                  d|fd||f      dt	        j
                         v st        j                  |      rt        j                  |      nddt	        j
                         v st        j                  t               rt        j                  t               ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}} y )	N)z	CLAUDE.mdz	MEMORY.md.envz	.env.keyszorganization-structure.jsonztask-timers.jsonztoken-ledger.jsonr(   )z7%(py0)s in %(py4)s
{%(py4)s = %(py2)s.PROTECTED_NAMES
}namer+   r-   r   r   assert %(py6)sr   )
r+   PROTECTED_NAMESr2   r3   r4   r5   r6   r7   r8   r9   )r;   r   r<   r>   @py_format5@py_format7s         r   test_protected_namesz"TestProtected.test_protected_names   s    ] 	.D---4-----4-------4---4------2---2-----------	.r   c                    dD ]  }t         j                  }||v }|st        j                  d|fd||f      dt	        j
                         v st        j                  |      rt        j                  |      nddt	        j
                         v st        j                  t               rt        j                  t               ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}} y )	N)zmemory/reportszmemory/researchzmemory/specszmemory/meetingszmemory/plansr(   )z6%(py0)s in %(py4)s
{%(py4)s = %(py2)s.PROTECTED_DIRS
}r   r+   r   r   r   )
r+   PROTECTED_DIRSr2   r3   r4   r5   r6   r7   r8   r9   )r;   r   r<   r>   r   r   s         r   test_protected_dirsz!TestProtected.test_protected_dirs   s    5 	*A)))1)))))1)))))))1)))1))))))))))))))))))))	*r   r"   c                    t         j                  }d}||z  }t        |      } |||      }|sddt        j                         v st        j                  t               rt        j                  t               ndt        j                  |      dt        j                         v st        j                  t              rt        j                  t              nddt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dz  }t        t        j                  |            d x}x}x}x}}y )Nr   zassert %(py12)s
{%(py12)s = %(py2)s
{%(py2)s = %(py0)s.is_protected
}(%(py9)s
{%(py9)s = %(py3)s((%(py4)s / %(py6)s))
}, %(py10)s)
}r+   r   r"   )r-   r   rN   r   r   r
   rP   py12
r+   is_protectedr   r4   r5   r2   r6   r7   r8   r9   )r;   r"   r>   @py_assert5rR   @py_assert8@py_assert11@py_format13s           r   test_env_is_protectedz#TestProtected.test_env_is_protected   s    @f@8f#4@s#45@5x@@@@@@@@r@@@r@@@@@@@@@s@@@s@@@@@@8@@@8@@@f@@@5@@@@@@x@@@x@@@@@@@@@@@r   c                     t         j                  }d}||z  }d}||z  }d}||z  }t        |      }	 ||	|      }
|
sddt        j                         v st        j                  t               rt        j                  t               ndt        j                  |      dt        j                         v st        j                  t              rt        j                  t              nddt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      t        j                  |      t        j                  |	      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |
      d
z  }t        t        j                  |            d x}x}x}x}x}x}x}x}	}
y )	Nr]   r   zrpt.mdzassert %(py18)s
{%(py18)s = %(py2)s
{%(py2)s = %(py0)s.is_protected
}(%(py15)s
{%(py15)s = %(py3)s((((%(py4)s / %(py6)s) / %(py9)s) / %(py12)s))
}, %(py16)s)
}r+   r   r"   )
r-   r   rN   r   r   r
   r   py15r   py18r   )r;   r"   r>   r   rR   r   r   r   r   @py_assert14@py_assert17@py_format19s               r   test_reports_subfile_protectedz,TestProtected.test_reports_subfile_protected   s.   YhY8h#6YY#6#BYXY#BX#MYs#MNYNPXYYYYYYYYrYYYrYYYYYYYYYsYYYsYYYYYY8YYY8YYYhYYYYYYXYYYNYYYYYYPXYYYPXYYYYYYYYYYYYr   c                    t         j                  }d}||z  }d}||z  }t        |      } |||      }| }	|	sddt        j                         v st        j                  t               rt        j                  t               ndt        j                  |      dt        j                         v st        j                  t              rt        j                  t              nddt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      t        j                  |      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      d	z  }
t        t        j                  |
            d x}x}x}x}x}x}x}}	y )Nr$   zgarbage.txtzassert not %(py15)s
{%(py15)s = %(py2)s
{%(py2)s = %(py0)s.is_protected
}(%(py12)s
{%(py12)s = %(py3)s(((%(py4)s / %(py6)s) / %(py9)s))
}, %(py13)s)
}r+   r   r"   )	r-   r   rN   r   r   r
   r   py13r   r   )r;   r"   r>   r   rR   r   r   r   r   @py_assert16r   s              r   test_normal_file_not_protectedz,TestProtected.test_normal_file_not_protected   s   ??S%Sx%'7S-S'7-'GS3'G#HS?#H(SSSSSSSSSSS2SSS2SSS?SSSSSS3SSS3SSSSSSxSSSxSSS%SSS-SSS#HSSSSSS(SSS(SSSSSSSSSSSr   )r   N)	rV   rW   rX   r   r   r   r   r   r   rY   r   r   r   r      sN    .
*
Ad At AZt Z ZTt T Tr   r   c                   \    e Zd Zdedej
                  ddfdZdedej
                  ddfdZy)
TestDryRunr"   capsysr   Nc                    t        |dz  dz  d      }t        j                  |d|dz  dz         |j                  } |       }|sd	d
t	        j
                         v st        j                  |      rt        j                  |      nd
t        j                  |      t        j                  |      dz  }t        t        j                  |            d x}}y )Nr$   	stale.txtrj   r'   Tr   r   r   dry_runcokacdir_wsAassert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.exists
}()
}r*   r   r   r+   run_cleanupexistsr4   r5   r2   r6   r7   r8   r9   )r;   r"   r   r*   r>   r<   r   s          r   test_no_deletionzTestDryRun.test_no_deletion   s    5 ;.R8
4#+k#9K#G 	 	Ixxxzzqqxzr   c                    t        |dz  dz  d       t        j                  |d|dz  dz         |j                         j                  }d}||v }|st        j                  d	|fd
||f      t        j                  |      dt        j                         v st        j                  |      rt        j                  |      nddz  }dd|iz  }t        t        j                  |            d x}}y )Nr$   r   rj   r'   Tr   r   r   r(   )z%(py1)s in %(py3)sout)py1rN   zassert %(py5)sr.   )r   r+   r   
readouterrr  r2   r3   r7   r4   r5   r6   r8   r9   )r;   r"   r   r  @py_assert0@py_assert2@py_format4@py_format6s           r   test_output_mentions_candidatez)TestDryRun.test_output_mentions_candidate   s    Hu{*4
4#+k#9K#G 	 	I!%%!{c!!!!{c!!!{!!!!!!c!!!c!!!!!!!r   )rV   rW   rX   r   pytestCaptureFixturer  r
  rY   r   r   r   r      sD     v7L7L QU "t "VEZEZ "_c "r   r   c                   <    e Zd ZdeddfdZdeddfdZdeddfdZy)TestExecuter"   r   Nc                    t        |dz  dz  d      }t        j                  |d|dz  dz         |j                  } |       }| }|sd	d
t	        j
                         v st        j                  |      rt        j                  |      nd
t        j                  |      t        j                  |      dz  }t        t        j                  |            d x}x}}y )Nr$   r%   rj   r'   Fr   r   r   zEassert not %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.exists
}()
}r*   r   r   )r;   r"   r*   r>   r<   r   r	  s          r   test_deletes_old_tmpz TestExecute.test_deletes_old_tmp   s    5 9,26
5#+k#9K#G 	 	I888::~~118:r   c                    t        |dz  d      }t        j                  |d|dz  dz         |j                  } |       }|sdd	t	        j
                         v st        j                  |      rt        j                  |      nd	t        j                  |      t        j                  |      d
z  }t        t        j                  |            d x}}y )Nr   i  r'   Fr   r   r   r   envr   r   )r;   r"   r  r>   r<   r   s         r   test_preserves_envzTestExecute.test_preserves_env   s    (V##.
5#+k#9K#G 	 	Izzz||ssz|r   c                    t        |dz  dz  d      }t        j                  |d|dz  dz         |j                  } |       }|sd	d
t	        j
                         v st        j                  |      rt        j                  |      nd
t        j                  |      t        j                  |      dz  }t        t        j                  |            d x}}y )Nr$   z	fresh.txt   r'   Fr   r   r   r   r*   r   r   )r;   r"   r*   r>   r<   r   s         r   test_preserves_recent_tmpz%TestExecute.test_preserves_recent_tmp   s    5 ;.Q7
5#+k#9K#G 	 	Ixxxzzqqxzr   )rV   rW   rX   r   r  r  r  rY   r   r   r  r     s;    T d 4 D $ 4 r   r  c                   <    e Zd ZdeddfdZdeddfdZdeddfdZy)
TestReportr"   r   Nc                    t         j                  ||dz  dz        }h d}|j                  } |       }||k  }|st        j                  d|fd||f      t        j
                  |      dt        j                         v st        j                  |      rt        j
                  |      ndt        j
                  |      t        j
                  |      dz  }d	d
|iz  }t        t        j                  |            d x}x}x}}y )Nr   r   r   r   >   
categoriestotal_candidatestotal_size_bytes)<=)zC%(py1)s <= %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.keys
}()
}r)r  rN   r.   r/   r	   r
   )r+   build_reportkeysr2   r3   r7   r4   r5   r6   r8   r9   )	r;   r"   r  r  rQ   r=   r  r?   r@   s	            r   test_report_keyszTestReport.test_report_keys   s    OOh(0;(>(L  NEQQQEQQQQEQQQEQQQQQQQQQQQQQQQQQQQQQQr   c                    t        |dz  dz  d       t        |dz  dz  d       t        j                  ||dz  dz  	      }|d
   }d}||k\  }|slt        j                  d|fd||f      t        j
                  |      t        j
                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr$   za.txtrj   r'   zb.txt   r   r   r  r  r  )>=)z%(py1)s >= %(py4)sr  r   r   r   r   r+   r   r2   r3   r7   r8   r9   r;   r"   r  r  r<   r  r   r   s           r   test_report_countszTestReport.test_report_counts   s    Huw&R0Huw&R0OOh(0;(>(L  N#$))$))))$)))$))))))))))r   c                 f   t        |dz  dz  dd       t        j                  ||dz  dz        }|d	   }d
}||kD  }|slt        j                  d|fd||f      t        j
                  |      t        j
                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}y )Nr$   zbig.txtrj      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r   r   r   r   r  r  r   )>)z%(py1)s > %(py4)sr&  r   r   r'  r(  s           r   test_report_size_positivez$TestReport.test_report_size_positive   s    Huy(r:FOOh(0;(>(L  N#$(q($q(((($q((($(((q(((((((r   )rV   rW   rX   r   r"  r)  r-  rY   r   r   r  r     s>    R R$ R
*4 *D *)$ )4 )r   r  )r   x)r   )7__doc__builtinsr4   _pytest.assertion.rewrite	assertionrewriter2   importlib.util	importlibr   sysr   pathlibr   r  r   insertr   __file__r   utilspec_from_file_locationr   r>   r  loaderr   r5   r6   r7   @py_format3appendr   _format_boolopr?   r@   r8   r9   module_from_specr+   exec_moduler   r   r   r!   r[   rp   r   r   r   r   r   r   r  r  rY   r   r   <module>rB     s   I    $ $   3tH~,,334 5..h..558NN	 u u      u   u    u                     ^^$$U+    
d % c D $ e D 6 6&< <(> >(: : = =? ?<W W,T T." "" ,) )r   