
    
jQ                       d dl m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mZ d dlmZ d dlZ ee      j$                  Ze	j(                  j+                  de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'ejP                  ejR                  <   ej2                  jU                  e'       ddZ+d Z,d Z-d Z.d Z/d Z0ddZ1y)    )annotationsN)Path)Any
continuouszcontinuous_lifecycle.pyz%(py2)spy2SPECz#%(py6)s
{%(py6)s = %(py4)s.loader
})py4py6zassert %(py9)spy9c                    ddt         j                  t         j                  ddt         j                  t         j                  dgdddi d	gd
dddddidt         j                  ddddt         j                  dgddidgg d g g i i g dS )NAWAITING_ACTIVATION   )state
generation
session_idsid_hashF0)enabledroute
collectingr      r   cursoranswersconsumed_updates	COMMITTED   r   )r   r   
message_idpayloadcustomer)r   r   r   r   roler   r   )	bootstrapr    workflowpublicationoutboxowner_callbackswizardgenerationscardsdrafts
deliveries
activation)mSESSIONSIDCUSTOMER     /home/cube/projects/richard/traning coach/.omo/evidence/task26/task26-continuous-lifecycle-observer-st_01a007da-v1/test_continuous_lifecycle.pybaser4      s     +))	
 !&QZZ0MN!!$	
  .	
  ii$!"**c*#\2

 K& &r2   c                    t         j                  t                     } | j                  }d}||k(  }|st	        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}}| j                  }d}||k(  }|st	        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}}| j                  }d
}||k(  }|st	        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}}t         j                  }|j                  }d} ||      }|sddt        j                         v st	        j                  t               rt	        j                  t               ndt	        j                  |      t	        j                  |      t	        j                  |      t	        j                  |      dz  }t        t	        j                  |            d x}x}x}}y )NREADY_CUSTOMER_ONBOARDING==z.%(py2)s
{%(py2)s = %(py0)s.status
} == %(py5)sppy0r   py5assert %(py7)spy7161z2%(py2)s
{%(py2)s = %(py0)s.message_id
} == %(py5)szsubmit_answer:date_of_birth)z.%(py2)s
{%(py2)s = %(py0)s.action
} == %(py5)s30bcd663zkassert %(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.SUCCESSOR
}.startswith
}(%(py6)s)
}r-   r<   r   r	   r
   py8)r-   classifyr4   status
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   action	SUCCESSOR
startswith)	r:   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert5@py_assert7@py_format9s	            r3   )test_current_prompt_and_successor_bindingrZ   >   s   	

46A882228222228222222212221222822222222222<< 5 <5    <5      1   1   <   5       884448444448444444414441444844444444444;;-;!!-*-!*--------1---1---;---!---*----------r2   c            	     T
   t               } | d   j                  dd       | d   j                  ddddi	       t        | d
   d   ddddi	      | d
   d<   t        j	                  |       }|j
                  }d}||k(  }|st        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}}|j                  }d}||k(  }|st        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}}|j                  }|j                   }d} ||      }|sd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}}d| d   d<   | d   j                  ddddi	       t        | d
   d   dddt        j"                  dgddi      | d
   d<   t        j	                  |       }|j
                  }d}||k(  }|st        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}}|j$                  }t        j"                  }||k(  }|st        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      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}x}}y )$Nr#   customer_attestation   )r   r   r$         r   r   r   r   r%   READY_CUSTOMER_ATTESTr7   r9   r:   r;   r>   r?   190rA   znon2:attest:23:zhassert %(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.action
}.startswith
}(%(py6)s)
}rC   owner_review      ownerr   r   r   r!   r   r   READY_OWNER_ONBOARDING_APPROVE)zH%(py2)s
{%(py2)s = %(py0)s.actor
} == %(py6)s
{%(py6)s = %(py4)s.OWNER
}r-   )r<   r   r	   r
   zassert %(py8)srD   )r4   updatedictr-   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   r   rO   rQ   OWNERactor)sr:   rR   rS   rT   rU   rV   rW   rX   rY   @py_format7s              r3   1test_onboarding_handoffs_learn_committed_messagesrp   F   se   AjM5bAm#9O/P   	(B01	AhKO 	


1A88...8.....8.......1...1...8...........<< 5 <5    <5      1   1   <   5       881810101111111111111111811111101111111111+AjM'm#/H   	(Bwwn.)AhKO 	


1A88777877777877777771777177787777777777777agg7g7g117aagr2   c            	        t               } ddi ddgd| d<   | d   j                  dd	d
di       t        | d   d   dd	dt        j                  dgd
di      | d   d<   t        j                  |       }|j                  }d}||k(  }|st        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}}d}t        j                  }||z   }|j                   }	||	v }
|
s
t        j                  d|
fd||	f      t        j                  |      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}x}x}
}	d}|j                   }||v }|st        j                  d|fd ||f      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}}d"}|j                   }||v }|st        j                  d|fd ||f      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readyr]   r      r   r#   r$         r   r`   r%   ra   rg   r   rh   !READY_OPERATOR_ACTIVATION_CUTOVERr7   r9   r:   r;   r>   r?   z--bootstrap-session )in)zX(%(py1)s + %(py4)s
{%(py4)s = %(py2)s.SESSION
}) in %(py9)s
{%(py9)s = %(py7)s.command
}r-   )py1r   r	   r?   r   zassert %(py11)spy11z--expected-generation 5)z/%(py1)s in %(py5)s
{%(py5)s = %(py3)s.command
})rx   py3r=   z<CHECKLIST_EVIDENCE>)r4   rj   rk   r-   rl   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   r.   command)rn   r:   rR   rS   rT   rU   rV   @py_assert0rW   @py_assert8@py_assert6@py_format10@py_format12@py_assert2s                 r3   ,test_ready_emits_exact_operator_cutover_gater   g   s   A #J	AjM mrcGWCUV	(Bwwn'"AhKO 	


1A88:::8:::::8:::::::1:::1:::8:::::::::::!:AII:!I-::-::::-:::!::::::A:::A:::I:::::::::::::::::::$1		1$	1111$	111$111111111111	1111111!.QYY.!Y....!Y...!......Q...Q...Y.......r2   c            	     :   t               } d| d   d<   d| d   d<   d| d   d<   t        j                  } ||       }|j                  }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                  |      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}}ddddt        j                  dgd d| d<   t        j                  } ||       }|j                  }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                  |      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}}| d   j                  ddd       t        j                  } ||       }|j                  }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                  |      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}}dt        j                  dddd g| d!<   dd"d#t        j                  t        j                  dd$dd%g| d&<   d't        j                  dd(d)i| d*<   t        j                  |       }|j                  }d+}||k(  }	|	st	        j
                  d
|	fd,||f      d-t        j                         v st	        j                  |      rt	        j                  |      nd-t	        j                  |      t	        j                  |      d.z  }
d/d0|
iz  }t        t	        j                  |            d x}x}	}|j                   }d#}||k(  }	|	st	        j
                  d
|	fd1||f      d-t        j                         v st	        j                  |      rt	        j                  |      nd-t	        j                  |      t	        j                  |      d.z  }
d/d0|
iz  }t        t	        j                  |            d x}x}	}d2| d*   d'   d3<   t        j                  } ||       }|j                  }d4}||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                  |      t	        j                  |      dz  }dd|iz  }t        t	        j                  |            d x}x}x}x}}d5t        j                  dd'd6d7t        j                  dd8i| d9<   t        j                  } ||       }|j                  }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                  |      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}}d;| d   d<   t        j                  } ||       }|j                  }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                  |      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ACTIVEr"   r      r   Tr    r   READY_CUSTOMER_START_CHECKINr7   )zk%(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.classify
}(%(py3)s)
}.status
} == %(py10)sr-   rn   )r<   r   rz   r=   r?   py10zassert %(py12)spy12wiz1   calories201r   )r   versionstepr   r   finalized_event_idr'   READY_CUSTOMER_CHECKIN_ANSWERsummary   evt1)r   r   r   WAIT_AUTOMATIC_GENERATIONtok1	generated)tokencustomer_keyr   r   r   r(   	published210)user_idchat_idtopic_id)r   r   r   destinationr   r)   draft1created)r   r   rF   r*   READY_OWNER_DRAFT_REVIEWr9   r:   r;   r>   r?   rA   approvedrF   READY_OWNER_EXPLICIT_SENDdsent_audited220)r   r   draft_idrF   r   provider_chat_idprovider_topic_idr+   READY_OPERATOR_DISABLEFREADY_CLEANUP_HANDOFF)r4   r-   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   r0   rj   KEYrl   r   )rn   rR   rS   r~   @py_assert9r}   @py_format11@py_format13r:   rT   rU   rV   s               r3   6test_active_checkin_generation_review_delivery_cleanupr      s   A&AkN7#$AkN< #AjM)::A:a=A=A#AA#AAAAA#AAAAAAA1AAA1AAA:AAAAAAaAAAaAAA=AAAAAA#AAAAAAAA**c""AhK ::B:a=B=B#BB#BBBBB#BBBBBBB1BBB1BBB:BBBBBBaBBBaBBB=BBBBBB#BBBBBBBBhKIrfM::>:a=>=>#>>#>>>>>#>>>>>>>1>>>1>>>:>>>>>>a>>>a>>>=>>>>>>#>>>>>>>> EE  	
Am  '(ww177PST	
AgJ 	155)TAhK 	


1A881118111118111111111111111811111111111<< 5 <5    <5      1   1   <   5       &0AhK(#::>:a=>=>#>>#>>>>>#>>>>>>>1>>>1>>>:>>>>>>a>>>a>>>=>>>>>>#>>>>>>>>EE  $ !

!$

AlO ::;:a=;=;#;;#;;;;;#;;;;;;;1;;;1;;;:;;;;;;a;;;a;;;=;;;;;;#;;;;;;;;$AjM)::::a=:=:#::#:::::#:::::::1:::1::::::::::a:::a:::=::::::#:::::::::r2   c                    t               } t        j                  t        j                  |             }d|d   d<   d|d   d<   t        j                  | |       t        j                  t        j                        5  t        j                  ||        d d d        t        j                  t        j                  |            }|d   j                  t        |d   d                t        j                  t        j                        5  t        j                  |       d d d        t        j                  t        j                  |            }dd	g|d   d   d
<   t        j                  t        j                        5  t        j                  |       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)N   r#   r   r$   r   r%   r   9r   r   )r4   jsonloadsdumpsr-   validate_transitionpytestraisesLifecycleErrorappendrk   validate_snapshot)abbads      r3   8test_monotonic_guard_rejects_stale_duplicate_wrong_router      s>   A

4::a=!AAjM(%&Am\"!Q	q''	(	a# 
)
**TZZ]
#CMc(mA./0	q''	(	C  
)
**TZZ]
#C!$c
CM!W	q''	(	C  
)	( 
)	( 
)	( 
)	(s$   <F	F+?F7F(+F47G c                (   | dz  }t         j                  |ddi       t         j                  |ddi       |j                  } |       }|j                  }d}||z  }t	        |      }d}||k(  }	|	sFt        j                  d|	fd||f      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                  |      t        j                  |      t        j                  |      dz  }
dd|
iz  }t        t        j                  |            d x}x}x}x}x}x}x}	}|j                         j                         D cg c]  }t        j                   |       }}|d   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}}y c c}w )Nzevents.jsonlrF   ABi  0o600r7   )z%(py12)s
{%(py12)s = %(py0)s((%(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s
{%(py3)s = %(py1)s.stat
}()
}.st_mode
} & %(py9)s))
} == %(py15)soctr:   )r<   rx   rz   r=   r?   r   r   py15zassert %(py17)spy17r   previous_event_sha256r   event_sha256)z%(py1)s == %(py4)s)rx   r	   zassert %(py6)sr
   )r-   append_eventstatst_moder   rG   rH   rI   rJ   rK   rL   rM   rN   	read_text
splitlinesr   r   )tmp_pathr:   r   rS   r~   r}   @py_assert10@py_assert11@py_assert14@py_assert13@py_format16@py_format18xrowsr|   rT   @py_format5ro   s                     r3   .test_append_ledger_is_private_and_hash_chainedr      s   >!ANN1xo&NN1xo&vv3vx3x3%3%'33'(3G3(G3333(G33333333333333333q333q333v333x333333%333(333G33333333#$;;=#;#;#=>#=aDJJqM#=D>7*+FtAw~/FF+/FFFFF+/FFFF+FFF/FFFFFFFF ?s   'J)returnzdict[str, Any])r   r   )2
__future__r   builtinsrI   _pytest.assertion.rewrite	assertionrewriterG   importlib.util	importlibr   syspathlibr   typingr   r   __file__parentHEREutilspec_from_file_locationr   rR   r|   loaderrW   rJ   rK   rL   @py_format3r   ro   _format_booloprV   r   rM   rN   module_from_specr-   modulesnameexec_moduler4   rZ   rp   r   r   r   r   r1   r2   r3   <module>r      s2   "      
   H~~~--$22 t t      t   t    t                     NN##D)DII     'T.B/08;v!$Gr2   