+
    G6„j  c                   óP  € ^ RI t^ RIHu Ht ^ RIt^ RIHt ^ RI	H
t
 ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHtHtHtHt ^ RIHt ^ R	IHt ^ R
IHt ]P<                  P>                  R 4       t ]P<                  P>                  R 4       t!]P<                  P>                  R 4       t"R# )é    N)Ústatus)Úget_database)Úcreate_sessionÚclaim_session_atomicallyÚget_session_by_id)Úget_or_create_conversation)Úcreate_message)Úactive_sessionsÚadd_active_sessionÚget_active_sessionsÚremove_active_session)Úcreate_agent)Úcreate_access_token)Ú	AsyncMockc              ƒ   ó<  "  € \        4       p\        VR R7      G Rj  x€L
 pVR,          p\        4       p\        VR V4       V\        9   qU'       gö   \
        P                  ! RV3RV\        34      RR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MRRR\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      MR/,          pRR	V/,          p\        \
        P                  ! V4      4      hRpV P                  R
RVRR/R7      pVP                  p\        P                   q•V	8H  qª'       Eg   \
        P                  ! RV
3RWY34      RR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MRR\
        P                  ! V4      R	R\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      MRR\
        P                  ! V	4      /,          pRRV/,          p\        \
        P                  ! V4      4      hR;p;r©VP#                  4       R,          pRq­V
8H  qî'       gy   \
        P                  ! RV3RWÚ34      R\
        P                  ! V4      R	\
        P                  ! V
4      /,          pRRV/,          p\        \
        P                  ! V4      4      hR;p;rêVP#                  4       R,          pRq­V
8H  qî'       gy   \
        P                  ! RV3RWÚ34      R\
        P                  ! V4      R	\
        P                  ! V
4      /,          pRRV/,          p\        \
        P                  ! V4      4      hR;p;rêV\        9  qU'       gö   \
        P                  ! RV3RV\        34      RR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MRRR\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      MR/,          pRR	V/,          p\        \
        P                  ! V4      4      hRp\%        W4      G Rj  x€L
 pVR,          pRq­V
8H  qî'       gy   \
        P                  ! RV3RWÚ34      R\
        P                  ! V4      R	\
        P                  ! V
4      /,          pRRV/,          p\        \
        P                  ! V4      4      hR;p;rêV P'                  R4      pVP                  p\        P                   q•V	8H  qª'       Eg   \
        P                  ! RV
3RWY34      RR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MRR\
        P                  ! V4      R	R\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      MRR\
        P                  ! V	4      /,          pRRV/,          p\        \
        P                  ! V4      4      hR;p;r©VP#                  4        Uu. uF  pVR,          NK  	  ppVV9  qU'       gê   \
        P                  ! RV3RVV34      RR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MRRR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MR/,          pRR	V/,          p\        \
        P                  ! V4      4      hRpR#  ELô ELu upi 5i) Úsite_demo_123©Úsite_idNÚ	sessionIdÚpy0ÚsidÚpy2r	   úassert %(py4)sÚpy4ú/api/v1/handoff/endÚendedByÚvisitor©ÚjsonÚresr   Úpy6úassert %(py8)sÚpy8ÚENDEDÚpy1úassert %(py6)sú/api/v1/admin/active-sessionsÚ	res_adminÚsids_returned©Úin©z%(py0)s in %(py2)s©ú==©zT%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py6)s
{%(py6)s = %(py4)s.HTTP_200_OK
}©z%(py1)s == %(py4)s©únot in©z%(py0)s not in %(py2)s)r   r   r   r
   r	   Ú
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanationÚpostÚstatus_coder   ÚHTTP_200_OKr   r   Úget)ÚclientÚdbÚsessionr   Úmock_wsÚ@py_assert1Ú@py_format3Ú@py_format5r   Ú@py_assert5Ú@py_assert3Ú@py_format7Ú@py_format9Ú@py_assert0Ú@py_assert2Ú
db_sessionr'   Úsr(   s   &                  ÚQC:\Users\alokc\chatbot\dev\chatbot\chatbot\backend\tests\test_end_chat_cleanup.pyÚBtest_ending_visitor_removes_session_from_in_memory_active_sessionsrO      sT  é € ä	‹€BÜ" 2¨Ô?×?€GØ
�+Õ
€Cô ‹k€GÜ�s˜O¨WÔ5Ø”/Ñ!×!×!×!Ó!ˆ3”/×!×!×!×!×!×!ˆ3×!×!×!Ò!ˆ3×!×!×!×!×!×!Ð!”/×!×!×!Ò!”/×!×!×!×!×!×!×!Ñ!ð �+‰+Ð+°;ÀÀYÐPYÐ2Zˆ+Ó
[€CØ�?‰?Ð0œf×0Ñ0Ð0Ð0Ñ0×0×0×0Ô0ˆ?×0×0×0×0×0×0ˆ3×0×0×0Ò0ˆ3×0×0Ö0ˆ?×0×0×0×0×0Ö0œf×0×0×0Ò0œf×0×0Ö0Ð0×0×0×0×0×0×0×0Ò0Ø�8‰8‹:�hÕÐ* 7Ð* 7Ñ*×*×*×*Ó*Ð×*×*Õ*Ð×*×*Ô* 7×*×*×*×*×*×*×*Ò*Ø�8‰8‹:�iÕ Ð- IÐ- IÑ-×-×-×-Ó-Ð ×-×-Õ-Ð ×-×-Ô- I×-×-×-×-×-×-×-Ò-ð ”oÑ%×%×%×%Ó%ˆ3”o×%×%×%×%×%×%ˆ3×%×%×%Ò%ˆ3×%×%×%×%×%×%Ð%”o×%×%×%Ò%”o×%×%×%×%×%×%×%Ñ%ô )¨Ó1×1€JØ�hÕÐ* 7Ð* 7Ñ*×*×*×*Ó*Ð×*×*Õ*Ð×*×*Ô* 7×*×*×*×*×*×*×*Ò*ð —
‘
Ð:Ó;€IØ× Ñ Ð6¤F×$6Ñ$6Ð6Ð$6Ñ6×6×6×6Ô6Ð ×6×6×6×6×6×6ˆ9×6×6×6Ò6ˆ9×6×6Ö6Ð ×6×6×6×6×6Ö6¤F×6×6×6Ò6¤F×6×6Ö6Ð$6×6×6×6×6×6×6×6Ò6Ø-6¯^©^Ô-=Ó>Ñ-=¨�Q�{—^�^Ñ-=€MÐ>Ø�mÑ#×#×#×#Ó#ˆ3�m×#×#×#×#×#×#ˆ3×#×#×#Ò#ˆ3×#×#×#×#×#×#Ð#�m×#×#×#Ò#�m×#×#×#×#×#×#×#Ó#ò3 @ò$ 2ùò ?ùs|   ‚`�`žB	`Â(A`Ã:C`ÇA'`ÉH`ÑA`Ò#A`Ô `ÔD `Ø"A'`Ú
A:`Ü`ÜA`Ý6A`ßA`à`à`c              ƒ   ó   "  € \        4       p\        VR R7      G Rj  x€L
 pVR,          p\        WRR7      G Rj  x€L
 pRqTVJqf'       g±   \        P                  ! R V3R!WE34      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pR	R
V/,          p\        \        P                  ! V4      4      hR;re\        4       p	\        VR V	RR7       V\        9   qf'       gö   \        P                  ! R"V3R#V\        34      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRRR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR/,          p
RRV
/,          p\        \        P                  ! V4      4      hRpV P                  RRVRR/R7      pVP                  p\         P"                  qÖV8H  qî'       Eg   \        P                  ! R$V3R%Wm34      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\
        P                  ! 4       9   g!   \        P                  ! \         4      '       d   \        P                  ! \         4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;ríVP%                  4       R,          pRpVV8H  qU'       gz   \        P                  ! R$V3R&VV34      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;r^VP%                  4       R,          pRpVV8H  qU'       gz   \        P                  ! R$V3R&VV34      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;r^V\        9  qf'       gö   \        P                  ! R'V3R(V\        34      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRRR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR/,          p
RRV
/,          p\        \        P                  ! V4      4      hRp\'        W4      G Rj  x€L
 pVR,          pRpVV8H  qU'       gz   \        P                  ! R$V3R&VV34      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;r^VR,          pRpVV8H  qU'       gz   \        P                  ! R$V3R&VV34      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;r^V P)                  R4      pVP%                  4        Uu. uF  pVR,          NK  	  ppW59  qf'       g±   \        P                  ! R'V3R)W534      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pR	R
V/,          p\        \        P                  ! V4      4      hR;reR#  ELã ELÈ EL,u upi 5i)*r   r   Nr   Úagent_clean_1)Úagent_idr   ÚclaimedÚpy3úassert %(py5)sÚpy5ÚIN_CHAT)Ú
status_valr   r   r	   r   r   r   r   Úagentr   r   r   r    r!   r"   r#   r$   r%   ÚassignedAgentIdr&   )úis not)z%(py0)s is not %(py3)sr)   r+   r,   r.   r/   r0   r2   )z%(py0)s not in %(py3)s)r   r   r   r3   r4   r5   r6   r7   r8   r9   r:   r   r
   r	   r;   r<   r   r=   r   r   r>   )r?   r@   rA   r   rS   rK   rC   Ú@py_format4Ú@py_format6rB   rD   rE   r   rF   rG   rH   rI   rJ   rL   r'   rM   s   &                    rN   Ú@test_ending_agent_removes_session_from_in_memory_active_sessionsr^   *   ss  é € ä	‹€BÜ" 2¨Ô?×?€GØ
�+Õ
€Cä,¨R¸ÔO×O€GØÐ˜$Ð×××Óˆ7××××××ˆ7×××Òˆ7××Ö˜$×××××××Ðä‹k€GÜ�s˜O¨WÀÕKØ”/Ñ!×!×!×!Ó!ˆ3”/×!×!×!×!×!×!ˆ3×!×!×!Ò!ˆ3×!×!×!×!×!×!Ð!”/×!×!×!Ò!”/×!×!×!×!×!×!×!Ñ!ð �+‰+Ð+°;ÀÀYÐPWÐ2Xˆ+Ó
Y€CØ�?‰?Ð0œf×0Ñ0Ð0Ð0Ñ0×0×0×0Ô0ˆ?×0×0×0×0×0×0ˆ3×0×0×0Ò0ˆ3×0×0Ö0ˆ?×0×0×0×0×0Ö0œf×0×0×0Ò0œf×0×0Ö0Ð0×0×0×0×0×0×0×0Ò0Ø�8‰8‹:�hÕÐ* 7Ð*Ð 7Ñ*×*×*×*Ó*Ð 7×*×*Õ*Ð×*×*Ô* 7×*×*×*×*×*×*×*Ò*Ø�8‰8‹:�iÕ Ð+ GÐ+Ð  GÑ+×+×+×+Ó+Ð  G×+×+Õ+Ð ×+×+Ô+ G×+×+×+×+×+×+×+Ò+ð ”oÑ%×%×%×%Ó%ˆ3”o×%×%×%×%×%×%ˆ3×%×%×%Ò%ˆ3×%×%×%×%×%×%Ð%”o×%×%×%Ò%”o×%×%×%×%×%×%×%Ñ%ô )¨Ó1×1€JØ�hÕÐ* 7Ð*Ð 7Ñ*×*×*×*Ó*Ð 7×*×*Õ*Ð×*×*Ô* 7×*×*×*×*×*×*×*Ò*ØÐ'Õ(Ð;¨OÐ;Ð(¨OÑ;×;×;×;Ó;Ð(¨O×;×;Õ;Ð(×;×;Ô;¨O×;×;×;×;×;×;×;Ò;ð —
‘
Ð:Ó;€IØ/8¯~©~Ô/?Ó@Ñ/?¨!�q˜—~�~Ñ/?Ð@Ð@ˆ3Ñ@×@×@×@Ó@ˆ3×@×@×@×@×@×@ˆ3×@×@×@Ò@ˆ3×@×@Ö@Ð@×@×@×@×@×@×@×@Ò@ò5 @ò Pò" 2ùò Aùs~   ‚`�` ž`»`¼A `ÂC `Å>A`ÇC`Ê/A'`ÌH`Ô+A`Õ=A`×`×E`Ü,`	Ü>A`ÞA%`à`à`à	`c              ƒ   ó  "  € \        4       p\        VR R7      G Rj  x€L
 pVR,          p\        WR 4      G Rj  x€L
 pVR,          p\        WVRR4      G Rj  x€L
  V P	                  RRVRR	/R
7       V P                  RV R24      pVP                  p\        P                  q‡V8H  q™'       Eg   \        P                  ! R"V	3R#Wx34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR\        P                  ! V4      /,          p
RRV
/,          p\        \        P                   ! V4      4      hR;p;r˜VP#                  4       pVR,          qÝV8H  qî'       g±   \        P                  ! R"V3R$WÓ34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\        \        P                   ! V4      4      hR;rÞVR,          pRq�V	8H  qî'       gy   \        P                  ! R"V3R%WÙ34      R\        P                  ! V4      R\        P                  ! V	4      /,          pRRV/,          p
\        \        P                   ! V
4      4      hR;p;réVR,          pR	q�V	8H  qî'       gy   \        P                  ! R"V3R%WÙ34      R\        P                  ! V4      R\        P                  ! V	4      /,          pRRV/,          p
\        \        P                   ! V
4      4      hR;p;réVR,          p\%        V4      p	^pV	V8H  qˆ'       gæ   \        P                  ! R"V3R&V	V34      RR\        P                  ! 4       9   g!   \        P                  ! \$        4      '       d   \        P                  ! \$        4      MRR\        P                  ! V4      R\        P                  ! V	4      R\        P                  ! V4      /,          pRR V/,          p\        \        P                   ! V4      4      hR;p;p	;ppVR,          ^ ,          R!,          pRq�V	8H  qî'       gy   \        P                  ! R"V3R%WÙ34      R\        P                  ! V4      R\        P                  ! V	4      /,          pRRV/,          p
\        \        P                   ! V
4      4      hR;p;réR#  ELe ELK EL/5i)'r   r   Nr   ÚconversationIdÚuserzMessage before endingr   r   rY   r   z/api/v1/session/z/history?siteId=site_demo_123r   Úres_histr   r   r   r    r!   r"   r$   rT   r   rU   rV   r#   r%   ÚmessagesÚlenÚpy7zassert %(py9)sÚpy9Úcontentr,   r.   )z%(py1)s == %(py3)sr/   )z0%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)s)r   r   r   r   r;   r>   r<   r   r=   r3   r4   r5   r6   r7   r8   r9   r:   r   rd   )r?   r@   rA   r   ÚconvÚconv_idrb   rC   rF   rG   rH   rI   ÚdatarJ   rK   r\   r]   rE   Ú@py_assert6Ú@py_format8Ú@py_format10s   &                    rN   Ú@test_ended_session_history_still_retrievable_via_restoration_apirn   I   s;  é € ä	‹€BÜ" 2¨Ô?×?€GØ
�+Õ
€Cä+¨B°_ÓE×E€DØÐ#Õ$€GÜ
˜ c¨6Ð3JÓ
K×KÐKð ‡K�KÐ%¨[¸#¸yÈ'Ð,R€KÔSð �z‰zÐ,¨S¨EÐ1NÐOÓP€HØ×ÑÐ5¤6×#5Ñ#5Ð5Ð#5Ñ5×5×5×5Ô5Ð×5×5×5×5×5×5ˆ8×5×5×5Ò5ˆ8×5×5Ö5Ð×5×5×5×5×5Ö5¤6×5×5×5Ò5¤6×5×5Ö5Ð#5×5×5×5×5×5×5×5Ò5Ø�=‰=‹?€DØ�ÕÐ# Ñ#×#×#×#Ó#Ð×#×#Õ#Ð×#×#×#×#×#Ö# ×#×#×#Ò# ×#×#×#×#×#×#×#Ò#Ø��>Ð$˜WÐ$˜WÑ$×$×$×$Ó$ˆ>×$×$Õ$ˆ>×$×$Ô$˜W×$×$×$×$×$×$×$Ò$Ø�	�?Ð%˜gÐ%˜gÑ%×%×%×%Ó%ˆ?×%×%Õ%ˆ?×%×%Ô%˜g×%×%×%×%×%×%×%Ò%Ø�JÕÐ%Œ3ÐÓ Ð% AÐ%Ð  AÑ%×%×%×%Ó%Ð  A×%×%×%×%×%×%Œ3×%×%×%Ò%Œ3×%×%Ö%Ð×%×%Ô%Ð ×%×%Ô% A×%×%×%×%×%×%×%Õ%Ø�
Õ˜AÕ˜yÕ)ÐDÐ-DÐDÐ-DÑD×D×D×DÓDÐ)×D×DÕDÐ)×D×DÔDÐ-D×D×D×D×D×D×D×DÔDò% @ò FâKùsN   ‚V�VžVºV»VÁVÁB(VÄA'VÅ+C2VÉG)VÑD;VÖVÖV)#Úbuiltinsr5   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter3   ÚpytestÚfastapir   Úapp.databaser   Ú#app.repositories.session_repositoryr   r   r   Ú(app.repositories.conversation_repositoryr   Ú#app.repositories.message_repositoryr   Úapp.services.presencer	   r
   r   r   Ú!app.repositories.agent_repositoryr   Úapp.utils.securityr   Úunittest.mockr   ÚmarkÚanyiorO   r^   rn   © ó    rN   Ú<module>r�      s‰   ðß  „ ƒÝ Ý %ß kÑ kÝ OÝ >ß qÓ qÝ :Ý 2Ý #à‡�×Ññ$ó ð$ð: ‡�×ÑñAó ðAð< ‡�×ÑñEó òEr€   