+
    Ã~jÔ  c                   ó¸   € ^ RI t^ RIHu Ht ^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHtHt R tR t]P(                  P*                  R 4       tR	 tR
 tR# )é    N)Ústatus)Úget_database)Úget_or_create_conversationÚget_conversation_by_session_id)Úcreate_messageÚget_messages_by_conversation_idc                 óÊ  € R \         P                  ! 4       P                  R,           R2pV P                  RRVRR/R7      pVP	                  4       R,          pR	R
V 2/pV P                  RRV/VR7      pVP	                  4       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#W‰3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,          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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êR# )&zmsg-ºNé   Nú.comú/api/v1/tenant/registerÚdomainÚnamezMessage Store©ÚjsonÚsiteIdÚOriginúhttp://ú/api/v1/session/init©r   ÚheadersÚ	sessionIdú/api/v1/messageÚmessageúHello WorldÚpy0Ú	msg_resp1Úpy2Úpy4r   Úpy6úassert %(py8)sÚpy8NÚpy1Úpy3Ú
session_idúassert %(py5)sÚpy5Úreplyú-Please wait while we connect you to an agent.úassert %(py6)s©ú==©zT%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py6)s
{%(py6)s = %(py4)s.HTTP_200_OK
}©z%(py1)s == %(py3)s©z%(py1)s == %(py4)s)ÚuuidÚuuid4ÚhexÚpostr   Ústatus_coder   ÚHTTP_200_OKÚ
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanation)Úclientr   Úreg_respÚsite_idr   Ú	init_respr$   r   Ú@py_assert1Ú@py_assert5Ú@py_assert3Ú@py_format7Ú@py_format9Ú@py_assert0Ú@py_assert2Ú@py_format4Ú@py_format6Ú@py_format5s   &                 ÚHC:\Users\alokc\chatbot\dev\chatbot\chatbot\backend\tests\test_message.pyÚtest_send_message_api_flowrL      s"  € à”D—J’J“L×$Ñ$ RÕ(Ð)¨Ð.€FØ�{‰{Ð4Ø�&Ø�ð<ˆ{ó €Hð �m‰m‹o˜hÕ'€Gà˜7 6 (Ð+Ð,€GØ—‘Ð2¸(ÀGÐ9LÐV]�Ó^€IØ—‘Ó! +Õ.€Jð —‘Ð-Ø�ZØ�=ð5�ó €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Ø�>‰>Ó˜KÕ(Ð6¨JÑ6×6×6×6Ó6Ð(×6×6Õ6Ð(×6×6×6×6×6Ö6¨J×6×6×6Ò6¨J×6×6×6×6×6×6×6Ò6Ø�>‰>Ó˜GÕ$ÐWÐ(WÐWÐ(WÑW×W×W×WÓWÐ$×W×WÕWÐ$×W×WÔWÐ(W×W×W×W×W×W×W×WÔWó    c                 óx  € R \         P                  ! 4       P                  R,           R2pV P                  RRVRR/R7      pVP	                  4       R,          pR	R
V 2/pV P                  RRV/VR7      pVP	                  4       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(W‰3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                  RRV/R7       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(W‰3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                  R"RV/R7       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*W‰3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©R%pVP	                  4       R&,          q­V
9   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# )-zstates-r	   r   r   r   r   zStates Storer   r   r   r   r   r   r   r   r   zFirst inquiryr   Úr1r   r   r   r   r    r!   Nr'   r(   r"   r)   z/api/v1/handoff/acceptzSecond inquiryÚr2zMessage delivered to agent.z/api/v1/handoff/endzThird inquiryÚr3zended sessionÚdetailr*   r,   r.   )z]%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py6)s
{%(py6)s = %(py4)s.HTTP_400_BAD_REQUEST
}©Úin©z%(py1)s in %(py4)s)r/   r0   r1   r2   r   r3   r   r4   r5   r6   r7   r8   r9   r:   r;   r<   ÚHTTP_400_BAD_REQUEST)r=   r   r>   r?   r   r@   r$   rO   rA   rB   rC   rD   rE   rF   rG   rJ   rP   rQ   s   &                 rK   Útest_send_message_all_statesrW      s  € Ø”t—z’z“|×'Ñ'¨Õ+Ð,¨DÐ1€FØ�{‰{Ð4Ø�&Ø�ð<ˆ{ó €Hð �m‰m‹o˜hÕ'€Gà˜7 6 (Ð+Ð,€GØ—‘Ð2¸(ÀGÐ9LÐV]�Ó^€IØ—‘Ó! +Õ.€Jð 
�‰Ð&¨k¸:ÀyÐRaÐ-bˆÓ	c€BØ�>‰>Ð/œV×/Ñ/Ð/Ð/Ñ/×/×/×/Ô/ˆ>×/×/×/×/×/×/ˆ2×/×/×/Ò/ˆ2×/×/Ö/ˆ>×/×/×/×/×/Ö/œV×/×/×/Ò/œV×/×/Ö/Ð/×/×/×/×/×/×/×/Ò/Ø�7‰7‹9�WÕÐPÐ!PÐPÐ!PÑP×P×P×PÓPÐ×P×PÕPÐ×P×PÔPÐ!P×P×P×P×P×P×P×PÒPð ‡K�KÐ(°¸ZÐ/H€KÔIð 
�‰Ð&¨k¸:ÀyÐRbÐ-cˆÓ	d€BØ�>‰>Ð/œV×/Ñ/Ð/Ð/Ñ/×/×/×/Ô/ˆ>×/×/×/×/×/×/ˆ2×/×/×/Ò/ˆ2×/×/Ö/ˆ>×/×/×/×/×/Ö/œV×/×/×/Ò/œV×/×/Ö/Ð/×/×/×/×/×/×/×/Ò/Ø�7‰7‹9�WÕÐ>Ð!>Ð>Ð!>Ñ>×>×>×>Ó>Ð×>×>Õ>Ð×>×>Ô>Ð!>×>×>×>×>×>×>×>Ò>ð ‡K�KÐ%¨[¸*Ð,E€KÔFð 
�‰Ð&¨k¸:ÀyÐRaÐ-bˆÓ	c€BØ�>‰>Ð8œV×8Ñ8Ð8Ð8Ñ8×8×8×8Ô8ˆ>×8×8×8×8×8×8ˆ2×8×8×8Ò8ˆ2×8×8Ö8ˆ>×8×8×8×8×8Ö8œV×8×8×8Ò8œV×8×8Ö8Ð8×8×8×8×8×8×8×8Ò8ØÐ1˜bŸg™g›i¨Õ1Ð1Ð1Ñ1×1×1×1Ó1ˆ?×1×1Õ1ˆ?×1×1Ô1Ð1×1×1×1×1×1×1×1Ô1rM   c               ƒ   óè  "  € \        4       p R \        P                  ! 4       P                  R,           2pR\        P                  ! 4       P                  R,           2p\	        WV4      G Rj  x€L
 pVR,          qDV8H  qU'       g±   \
        P                  ! RV3RWA3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;rEVR
,          qDV8H  qU'       g±   \
        P                  ! RV3RWB3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;rEVR,          pRq„V8H  qU'       gy   \
        P                  ! RV3RWH34      R\
        P                  ! V4      R\
        P                  ! V4      /,          p	RRV	/,          p
\        \
        P                  ! V
4      4      hR;p;rXVR,          p\	        WV4      G Rj  x€L
 pVR,          qDV8H  qU'       g±   \
        P                  ! RV3RWK3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;rE\        WVRR4      G Rj  x€L
 pVR,          qDV8H  qU'       g±   \
        P                  ! RV3RWK3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;rEVR,          pRq„V8H  qU'       gy   \
        P                  ! RV3RWH34      R\
        P                  ! V4      R\
        P                  ! V4      /,          p	RRV	/,          p
\        \
        P                  ! V
4      4      hR;p;rXVR,          pRq„V8H  qU'       gy   \
        P                  ! RV3RWH34      R\
        P                  ! V4      R\
        P                  ! V4      /,          p	RRV	/,          p
\        \
        P                  ! V
4      4      hR;p;rX\        W4      G Rj  x€L
 p\        V4      p^qõV8H  pV'       Eg   \
        P                  ! RV3RW_34      RR\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      MRRR\        P                  ! 4       9   g   \
        P                  ! V4      '       d   \
        P                  ! V4      MRR\
        P                  ! V4      R\
        P                  ! V4      /,          p
RRV
/,          p\        \
        P                  ! V4      4      hR;p;ppV^ ,          R,          pRq„V8H  qU'       gy   \
        P                  ! RV3RWH34      R\
        P                  ! V4      R\
        P                  ! V4      /,          p	RRV	/,          p
\        \
        P                  ! V
4      4      hR;p;rXR#  ELø EL½ ELã ELæ5i) Úsess_:Né   NÚsite_Nr   r"   r#   r$   r%   r&   r   r?   r   Úopenr   r)   r   ÚconversationIdÚconv_idÚuserr   ÚroleÚcontentr   ÚlenÚmessagesr    r!   r*   r-   r.   )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)s)r   r/   r0   r1   r   r5   r6   r:   r7   r8   r9   r;   r<   r   r   rb   )Údbr$   r?   Úconv1rF   rG   rH   rI   rC   rJ   rD   r^   Úconv2Úuser_msgrc   rB   Ú@py_assert4rE   s                     rK   Ú*test_conversation_and_message_repositoriesri   ?   s*  é € ô 
‹€BØœŸš›×)Ñ)¨#Õ.Ð/Ð0€JØ”d—j’j“l×&Ñ& sÕ+Ð,Ð-€Gô -¨R¸WÓE×E€EØ�ÕÐ+ Ñ+×+×+×+Ó+Ð×+×+Õ+Ð×+×+×+×+×+Ö+ ×+×+×+Ò+ ×+×+×+×+×+×+×+Ò+Ø��?Ð%˜gÑ%×%×%×%Ó%ˆ?×%×%Õ%ˆ?×%×%×%×%×%Ö%˜g×%×%×%Ò%˜g×%×%×%×%×%×%×%Ò%Ø��?Ð$˜fÐ$˜fÑ$×$×$×$Ó$ˆ?×$×$Õ$ˆ?×$×$Ô$˜f×$×$×$×$×$×$×$Ò$ØÐ$Õ%€Gô -¨R¸WÓE×E€EØÐ!Õ"Ð- gÑ-×-×-×-Ó-Ð"×-×-Õ-Ð"×-×-×-×-×-Ö- g×-×-×-Ò- g×-×-×-×-×-×-×-Ò-ô $ B°¸VÀ]ÓS×S€HØÐ$Õ%Ð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×0Ò0Ø�FÕÐ%˜vÐ%˜vÑ%×%×%×%Ó%Ð×%×%Õ%Ð×%×%Ô%˜v×%×%×%×%×%×%×%Ò%Ø�IÕÐ/ -Ð/ -Ñ/×/×/×/Ó/Ð×/×/Õ/Ð×/×/Ô/ -×/×/×/×/×/×/×/Ò/ô 5°RÓA×A€HÜˆx‹=Ð˜AÐ˜AÑ×××Õˆ=××××××Œ3×××ÒŒ3××××××Ðˆx×××Òˆx××Öˆ=××Ô˜A×××××××ÓØ�A�;�yÕ!Ð2 ]Ð2 ]Ñ2×2×2×2Ó2Ð!×2×2Õ2Ð!×2×2Ô2 ]×2×2×2×2×2×2×2Ô2ò' Fò Fò Tò Bùsv   ‚A,]2Á.]&Á/A>]2Ã.C]2Æ5C7]2Ê,])Ê-A>]2Ì,A]2Î	],Î
A>]2Ð	F ]2Ö	]/Ö
A2]2×=A]2ÙD]2Ý)]2Ý,]2Ý/]2c                 ó  € V P                  R RRRR/R7      pVP                  p\        P                  q2V8H  qD'       Eg   \        P
                  ! RV3RW#3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;rCRqqP                  4       R,          qGV9   qˆ'       gy   \        P
                  ! RV3RWt34      R\        P                  ! V4      R	\        P                  ! V4      /,          p	RRV	/,          p\        \        P                  ! V4      4      hR;p;r„R# )r   r   Úsess_nonexistent_999r   ÚHellor   r   Úmsg_respr   r   r   r   r    r!   NzSession not foundrR   r"   r)   r*   )z[%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py6)s
{%(py6)s = %(py4)s.HTTP_404_NOT_FOUND
}rS   rU   )r2   r3   r   ÚHTTP_404_NOT_FOUNDr5   r6   r7   r8   r9   r:   r;   r<   r   )
r=   rm   rA   rB   rC   rD   rE   rF   rG   rJ   s
   &         rK   Ú$test_send_message_unknown_session_idro   \   s   € Ø�{‰{Ð,ØÐ+Ø�7ð4ˆ{ó €Hð ×ÑÐ<¤6×#<Ñ#<Ð<Ð#<Ñ<×<×<×<Ô<Ð×<×<×<×<×<×<ˆ8×<×<×<Ò<ˆ8×<×<Ö<Ð×<×<×<×<×<Ö<¤6×<×<×<Ò<¤6×<×<Ö<Ð#<×<×<×<×<×<×<×<Ò<ØÐ;§-¡-£/°(Õ";Ð;Ð";Ñ;×;×;×;Ó;Ð×;×;Õ;Ð×;×;Ô;Ð";×;×;×;×;×;×;×;Ô;rM   c                 óÆ  € V P                  R RRRR/R7      pVP                  p\        P                  q2V8H  qD'       Eg   \        P
                  ! RV3RW#3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;rCR# )r   r   Úsess_valid_formatr   Ú r   r   rm   r   r   r   r   r    r!   Nr*   )zf%(py2)s
{%(py2)s = %(py0)s.status_code
} == %(py6)s
{%(py6)s = %(py4)s.HTTP_422_UNPROCESSABLE_ENTITY
})r2   r3   r   ÚHTTP_422_UNPROCESSABLE_ENTITYr5   r6   r7   r8   r9   r:   r;   r<   )r=   rm   rA   rB   rC   rD   rE   s   &      rK   Ú"test_send_message_validation_errorrt   d   sÇ   € Ø�{‰{Ð,ØÐ(Ø�2ð4ˆ{ó €Hð ×ÑÐG¤6×#GÑ#GÐGÐ#GÑG×G×G×GÔGÐ×G×G×G×G×G×Gˆ8×G×G×GÒGˆ8×G×GÖGÐ×G×G×G×G×GÖG¤6×G×G×GÒG¤6×G×GÖGÐ#G×G×G×G×G×G×G×GÔGrM   )Úbuiltinsr7   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter5   r/   ÚpytestÚfastapir   Úapp.databaser   Ú(app.repositories.conversation_repositoryr   r   Ú#app.repositories.message_repositoryr   r   rL   rW   ÚmarkÚanyiori   ro   rt   © rM   rK   Ú<module>r�      sP   ðß  „ ƒÛ Ý Ý %ß oß _òXò,2ðB ‡�×Ññ3ó ð3ò8<ôHrM   