Ë
    ­«ëj
  ã                   ó²   — d dl Zd dlmc mZ d dlmZ d dlm	Z	m
Z
mZmZmZmZmZmZ defd„Zdefd„Zdefd„Zd„ Zdefd	„Zdefd
„Zdefd„Zdefd„Zd„ Zy)é    N)ÚPath)Úclaim_batchÚensure_shared_rootÚis_rclone_configuredÚis_sensitive_pathÚlist_mountpointsÚmanifest_pathÚmanifest_writeÚresolve_shared_rootÚtmp_pathc                 ó|  — t        | dz  «      }d}| |z  }|j                  } |«       }||k(  }|�st        j                  d|fd||f«      dt	        j
                  «       v st        j                  |«      rt        j                  |«      nddt	        j
                  «       v st        j                  | «      rt        j                  | «      ndt        j                  |«      t        j                  |«      t        j                  |«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}x}x}x}}y )	NÚshared©ú==©zR%(py0)s == %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = (%(py2)s / %(py4)s).resolve
}()
}Úrootr   ©Úpy0Úpy2Úpy4Úpy7Úpy9úassert %(py11)sÚpy11)
r   ÚresolveÚ
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanation)	r   r   Ú@py_assert3Ú@py_assert5Ú@py_assert6Ú@py_assert8Ú@py_assert1Ú@py_format10Ú@py_format12s	            ú8/home/oem/CyberBrain26-unified/tests/test_shared_root.pyÚ!test_resolve_shared_root_explicitr,      sÅ   € Ü˜x¨(Ñ2Ó3€DØ'Ð2�H˜xÑ'Ð2Ð'×0Ñ0Ð2Ñ0Ó2Ð2ˆ4Ð2Ñ2×2×2Ö2ˆ4Ð2×2×2×2×2×2Ñ2ˆ4×2×2Ó2ˆ4×2×2×2×2×2Ò2�H×2×2Ó2�H×2×2Ô2˜x×2×2Ò2Ð0×2×2Ò2Ð2×2×2×2×2×2×2×2Ð2ó    c                 ó°  — |j                  dt        | dz  «      «       t        «       }d}| |z  }|j                  } |«       }||k(  }|�st	        j
                  d|fd||f«      dt        j                  «       v st	        j                  |«      rt	        j                  |«      nddt        j                  «       v st	        j                  | «      rt	        j                  | «      ndt	        j                  |«      t	        j                  |«      t	        j                  |«      dœz  }dd	|iz  }	t        t	        j                  |	«      «      ‚d x}x}x}x}}y )
NÚUNIFIED_INGEST_ROOTÚenvrootr   r   r   r   r   r   r   )ÚsetenvÚstrr   r   r   r   r   r   r    r!   r"   r#   )
r   Úmonkeypatchr   r$   r%   r&   r'   r(   r)   r*   s
             r+   Útest_resolve_shared_root_envr4      sÙ   € Ø×ÑÐ,¬c°(¸YÑ2FÓ.GÔHÜÓ €DØ(Ð3�H˜yÑ(Ð3Ð(×1Ñ1Ð3Ñ1Ó3Ð3ˆ4Ð3Ñ3×3×3Ö3ˆ4Ð3×3×3×3×3×3Ñ3ˆ4×3×3Ó3ˆ4×3×3×3×3×3Ò3�H×3×3Ó3�H×3×3Ô3˜y×3×3Ò3Ð1×3×3Ò3Ð3×3×3×3×3×3×3×3Ð3r-   c                 óÒ  — t        | dz  «      }dD ]ð  }||z  }|j                  } |«       }|sÎddt        j                  «       v st	        j
                  |«      rt	        j                  |«      nddt        j                  «       v st	        j
                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      dœz  }t        t	        j                  |«      «      ‚d x}x}}Œò d}||z  }d}||z  }	|	j                  }
 |
«       }|sµd	dt        j                  «       v st	        j
                  |«      rt	        j                  |«      ndt	        j                  |«      t	        j                  |«      t	        j                  |
«      t	        j                  |«      d
œz  }t        t	        j                  |«      «      ‚d x}x}x}x}	x}
}y )Nr   )ÚinboxÚ
processingÚsortedÚ
duplicatesÚindexÚtasksÚmanifestzMassert %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = (%(py0)s / %(py1)s).is_dir
}()
}r   Úsub)r   Úpy1r   Úpy6r<   zingest-manifest.jsonlz\assert %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = ((%(py0)s / %(py2)s) / %(py5)s).is_file
}()
})r   r   Úpy5Úpy8Úpy10)
r   Úis_dirr   r   r   r    r!   r"   r#   Úis_file)r   r   r=   Ú@py_assert2r$   r%   Ú@py_format7r(   Ú@py_assert4r&   Ú@py_assert7Ú@py_assert9Ú@py_format11s                r+   Ú'test_ensure_shared_root_creates_subdirsrK      s@  € Ü˜h¨Ñ1Ó2€DØ\ò %ˆØ�s‘
Ð$�
×"Ñ"Ð$Ñ"Ó$Ð$Ñ$×$×$×$×$Õ$�×$×$Ó$�×$×$×$×$×$Ò$�s×$×$Ó$�s×$×$Ô$Ð"×$×$Ò$Ð$×$×$×$×$×$Õ$ð%àÐBˆD�:ÑÐBÐ 7ÐBÐÐ 7Ñ7ÐBÐ7×@Ñ@ÐBÑ@ÓBÐBÑB×B×B×B×BÕBˆD×B×BÓBˆD×B×BÔB�:×B×BÒBÐ 7×B×BÒBÐ@×B×BÒBÐB×B×B×B×B×B×BÓBr-   c                  óž  — d} t        | «      }|s•ddt        j                  «       v st        j                  t         «      rt        j
                  t         «      ndt        j
                  | «      t        j
                  |«      dœz  }t        t        j                  |«      «      ‚d x} }d} t        | «      }|s•ddt        j                  «       v st        j                  t         «      rt        j
                  t         «      ndt        j
                  | «      t        j
                  |«      dœz  }t        t        j                  |«      «      ‚d x} }d} t        | «      }|s•ddt        j                  «       v st        j                  t         «      rt        j
                  t         «      ndt        j
                  | «      t        j
                  |«      dœz  }t        t        j                  |«      «      ‚d x} }d} t        | «      }|s•ddt        j                  «       v st        j                  t         «      rt        j
                  t         «      ndt        j
                  | «      t        j
                  |«      dœz  }t        t        j                  |«      «      ‚d x} }d} t        | «      }| }|s•d	dt        j                  «       v st        j                  t         «      rt        j
                  t         «      ndt        j
                  | «      t        j
                  |«      dœz  }t        t        j                  |«      «      ‚d x} x}}y )
Nz/home/u/.ssh/id_rsaz,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}r   ©r   r   r   zcredentials.jsonzfoo/secret.txtzkey.pemz/tmp/notes.txtz0assert not %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
})r   r   r   r   r    r!   r"   r#   )r(   r$   Ú@py_format5r%   Ú@py_format6s        r+   Útest_is_sensitive_pathrP   !   sÚ  € Ø2Ð3ÔÐ2Ó3Ð3Ñ3×3×3×3×3Õ3Ô×3×3Ó3Ô×3×3Ô3Ð2×3×3Ò3Ð3×3×3×3×3×3Ò3Ø/Ð0ÔÐ/Ó0Ð0Ñ0×0×0×0×0Õ0Ô×0×0Ó0Ô×0×0Ô0Ð/×0×0Ò0Ð0×0×0×0×0×0Ò0Ø-Ð.ÔÐ-Ó.Ð.Ñ.×.×.×.×.Õ.Ô×.×.Ó.Ô×.×.Ô.Ð-×.×.Ò.Ð.×.×.×.×.×.Ò.Ø&Ð'Ô˜YÓ'Ð'Ñ'×'×'×'×'Õ'Ô×'×'Ó'Ô×'×'Ô'˜Y×'×'Ò'Ð'×'×'×'×'×'Ò'Ø!1Ð2Ô Ð!1Ó2Ð2Ð2Ð2Ð2Ñ2×2×2×2×2Õ2Ô ×2×2Ó2Ô ×2×2Ô2Ð!1×2×2Ò2Ð2×2×2×2×2×2Õ2r-   c                 óh  — t        | dz  «      }t        ddi|¬«       t        |«      }|j                  } |«       }|s�ddt	        j
                  «       v st        j                  |«      rt        j                  |«      ndt        j                  |«      t        j                  |«      dœz  }t        t        j                  |«      «      ‚d x}}d}|j                  } |«       }||v }	|	sÁt        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   Úaé   )Úshared_rootzAassert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.exists
}()
}ÚmprM   )Úin)zH%(py1)s in %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.read_text
}()
})r>   Úpy3r@   r   úassert %(py9)sr   )r   r
   r	   Úexistsr   r   r   r    r!   r"   r#   Ú	read_textr   )r   r   rU   r(   r$   rN   Ú@py_assert0rG   r&   rE   Ú@py_format8r)   s               r+   Útest_manifest_write_and_pathr]   )   sÿ   € Ü˜h¨Ñ1Ó2€DÜ�C˜�8¨Õ.Ü	�tÓ	€BØ�9‰9Ð‰9‹;Ð‰;××××Õˆ2××Óˆ2××Ôˆ9××Òˆ;×××××ÒØÐ �"—,‘,Ð ‘,“.Ð ˆ3�.Ð × × Õ ˆ3�.× × Ó ˆ3× × × × × Ð �"× × Ó �"× × Ô �,× × Ò �.× × × × × × Ö r-   c                 óp  — t        | dz  «      }|dz  }|dz  j                  d«       |dz  j                  d«       t        |d¬«      }|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}}|d   }	t        |	«      }d
}
||
k(  }|sÉt        j                  d|fd||
f«      dt        j                  «       v st        j                  t        «      rt        j
                  t        «      ndt        j
                  |	«      t        j
                  |«      t        j
                  |
«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}	x}x}}
|d   }	t        |	«      }d
}
||
k(  }|sÉt        j                  d|fd||
f«      dt        j                  «       v st        j                  t        «      rt        j
                  t        «      ndt        j
                  |	«      t        j
                  |«      t        j
                  |
«      dœz  }dd|iz  }t        t        j                  |«      «      ‚d x}	x}x}}
d}	||	z  }|j                  } |«       }
|
 }|s¡ddt        j                  «       v st        j                  |«      rt        j
                  |«      ndt        j
                  |	«      t        j
                  |«      t        j
                  |
«      dœz  }t        t        j                  |«      «      ‚d x}	x}x}x}
}|dz  |d   z  }d}	||	z  }|j                  } |«       }
|
s¡ddt        j                  «       v st        j                  |«      rt        j
                  |«      ndt        j
                  |	«      t        j
                  |«      t        j
                  |
«      dœz  }t        t        j                  |«      «      ‚d x}	x}x}}
y )Nr   r6   znote.txtÚhelloz
secret.keyÚsecreté
   )rT   ÚlimitÚcountrS   r   )z%(py1)s == %(py4)s)r>   r   zassert %(py6)sr?   Úclaimed)z0%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)sÚlen)r   r   r   r   rX   r   ÚskippedzQassert not %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = (%(py0)s / %(py2)s).exists
}()
})r   r   r@   r   r7   Úbatch_idzMassert %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = (%(py0)s / %(py2)s).exists
}()
}Ú	batch_dir)r   Ú
write_textr   r   r   r!   r"   r#   re   r   r   r    rY   )r   r   r6   Úresultr[   r$   rE   rN   rF   r(   r&   r%   r\   r)   rG   r'   Ú@py_format9rh   s                     r+   Útest_claim_batch_moves_filesrl   1   s¼  € Ü˜h¨Ñ1Ó2€DØ�7‰N€EØ
ˆZÑ×#Ñ# GÔ,Ø
ˆ\Ñ×%Ñ% hÔ/Ü T°Ô4€FØ�'‰?Ð˜aÐˆ?˜aÑ××Õˆ?˜a××Óˆ?××Ò˜a××××××ÓØ�iÑ Ð&Œ3Ð Ó!Ð& QÐ&Ð! QÑ&×&×&Õ&Ð! Q×&×&×&×&×&Ñ&Œ3×&×&Ó&Œ3×&×&Ô&Ð ×&×&Ò&Ð!×&×&Ò& Q×&×&×&×&×&×&Õ&Ø�iÑ Ð&Œ3Ð Ó!Ð& QÐ&Ð! QÑ&×&×&Õ&Ð! Q×&×&×&×&×&Ñ&Œ3×&×&Ó&Œ3×&×&Ô&Ð ×&×&Ò&Ð!×&×&Ò& Q×&×&×&×&×&×&Õ&Ø"Ð,�˜
Ñ"Ð,Ð"×*Ñ*Ð,Ñ*Ó,Ð,Ð,Ð,Ð,Ñ,×,×,×,×,Õ,�×,×,Ó,�×,×,Ô,˜
×,×,Ò,Ð*×,×,Ò,Ð,×,×,×,×,×,×,Ð,Ø�|Ñ# f¨ZÑ&8Ñ8€IØ"Ð,ˆI˜
Ñ"Ð,Ð"×*Ñ*Ð,Ñ*Ó,Ð,Ñ,×,×,×,×,Õ,ˆI×,×,Ó,ˆI×,×,Ô,˜
×,×,Ò,Ð*×,×,Ò,Ð,×,×,×,×,×,×,r-   c                 óÒ  — |j                  dt        | dz  «      «       ddlm}  |«       }g }||k(  }|s­t	        j
                  d|fd||f«      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}}y )Nz1cyberbrain26.product.shared_root.SYNCTHING_CONFIGzno.xmlr   )Údetect_syncthing_foldersr   )z)%(py2)s
{%(py2)s = %(py0)s()
} == %(py5)srn   ©r   r   r@   úassert %(py7)sr   )Úsetattrr2   Ú cyberbrain26.product.shared_rootrn   r   r   r   r   r    r!   r"   r#   )r   r3   rn   r(   rG   r$   rO   r\   s           r+   Ú#test_detect_syncthing_folders_emptyrs   ?   s“   € Ø×ÑÐKÌSÐQYÐ\dÑQdÓMeÔfÝIá#Ó%Ð+¨Ð+Ð%¨Ñ+×+×+Õ+Ð%¨×+×+×+×+×+Ñ+Ð#×+×+Ó+Ð#×+×+Ô+Ð%×+×+Ò+¨×+×+×+×+×+×+Ô+r-   c                 óÚ  — |j                  dt        | dz  «      «       t        «       }d}||u }|sµt        j                  d|fd||f«      dt        j                  «       v st        j                  t        «      rt        j                  t        «      ndt        j                  |«      t        j                  |«      dœz  }dd	|iz  }t        t        j                  |«      «      ‚d x}x}}y )
Nz.cyberbrain26.product.shared_root.RCLONE_CONFIGzno.confF)Úis)z)%(py2)s
{%(py2)s = %(py0)s()
} is %(py5)sr   ro   rp   r   )rq   r2   r   r   r   r   r   r    r!   r"   r#   )r   r3   r(   rG   r$   rO   r\   s          r+   Útest_is_rclone_configured_falserv   F   s�   € Ø×ÑÐHÌ#ÈhÐYbÑNbÓJcÔdÜÓ!Ð* UÐ*Ð! UÐ*×*×*Õ*Ð! U×*×*×*×*×*Ñ*Ô×*×*Ó*Ô×*×*Ô*Ð!×*×*Ò* U×*×*×*×*×*×*Ô*r-   c                  ó”  — t        «       } t        | t        «      }|�s'ddt        j                  «       v st        j                  t        «      rt        j                  t        «      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                  t        «      rt        j                  t        «      ndt        j                  |«      dœz  }t        t        j                  |«      «      ‚d x} }y )NzLassert %(py6)s
{%(py6)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s()
}, %(py4)s)
}Ú
isinstancer   Úlist)r   r>   rW   r   r?   )
r   rx   ry   r   r   r   r    r!   r"   r#   )rE   r%   rF   s      r+   Ú"test_list_mountpoints_returns_listrz   K   s¡   € Ü&Ó(Ð/Œ:Ð(¬$Ó/Ð/Ò/×/×/×/×/Õ/Œ:×/×/Ó/Œ:×/×/×/×/×/Ò/Ô&×/×/Ó/Ô&×/×/Ô/Ð(×/×/×/×/×/Ð/¬$×/×/Ó/¬$×/×/Ô/Ð/×/×/×/×/×/Ó/r-   )Úbuiltinsr   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter   Úpathlibr   rr   r   r   r   r   r   r	   r
   r   r,   r4   rK   rP   r]   rl   rs   rv   rz   © r-   r+   ú<module>r�      s|   ðß  „ Õ ÷	÷ 	ó 	ð3°ó 3ð
4¨4ó 4ðC°dó Cò3ð!¨4ó !ð-¨4ó -ð,°$ó ,ð+¨dó +ó
0r-   