
    *j                    p    d Z ddlmZ ddlZddlmc mZ ddl	m
Z
mZ d Zd Zd Zd Zd	 Zd
 Zd Zd ZdS )z*Tests for runtime/conversation/session.py.    )annotationsN)SessionSessionStorec            	        t          d          } |                     d           |                     d           | j        } |            }t	          |          }d}||k    }|st          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
        |          d
z  }dd|iz  }t          t          j        |                    d x}x}x}x}}|                                 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         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 S )Ntest-personaslugHelloz
Greetings.   ==ze%(py7)s
{%(py7)s = %(py0)s(%(py5)s
{%(py5)s = %(py3)s
{%(py3)s = %(py1)s.history
}()
})
} == %(py10)slenspy0py1py3py5py7py10assert %(py12)spy12r   roleuser)z%(py1)s == %(py4)s)r   py4zassert %(py6)spy6   	assistant)r   add_useradd_assistanthistoryr   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation)r   @py_assert2@py_assert4@py_assert6@py_assert9@py_assert8@py_format11@py_format13@py_assert0@py_assert3@py_format5@py_format7s               C/Users/jameslopez/projects/MentorCore/tests/runtime/test_session.pytest_session_add_messagesr7      s    ^$$$AJJwOOL!!!y yy{{ 3{ q q          q            3     3             q     q      y    {        q                               99;;q>&!+V+!V++++++++++!V+++++!++++V+++++++++++++++++++++++++++99;;q>&!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00000000000000000000000    c            	     B   t          d          } |                     d           |                                 }|                    ddd           | j        } |            }t	          |          }d}||k    }|st          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
        |          dz  }dd|iz  }t          t          j        |                    d x}x}x}x}}d S )Nr   r   Hir   extra)r   contentr   r   r   r   r   r   r   r   )r   r    r"   appendr   r#   r$   r%   r&   r'   r(   r)   r*   )	r   hr+   r,   r-   r.   r/   r0   r1   s	            r6   test_session_history_is_copyr?      s   ^$$$AJJt			AHHf11222y yy{{ 3{ q q          q            3     3             q     q      y    {        q                                 r8   c                 8   t          d          } |                     d           |                                  | j        } |            }g }||k    }|st	          j        d|fd||f          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}}d S )
Nr   r   r
   r   )zF%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.history
}()
} == %(py7)sr   )r   py2r   r   zassert %(py9)spy9)r   r    clearr"   r#   r$   r%   r&   r'   r(   r)   r*   )r   @py_assert1r3   r-   @py_assert5@py_format8@py_format10s          r6   test_session_clearrH      s3   ^$$$AJJwGGIII999;;";";"119;"r8   c            	        t                      } |                     d          }| j        }|j        } ||          }||u }|s9t	          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        |          rt	          j	        |          ndt	          j	        |          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}x}x}}d S )	Nzmarcus-aureliusis)zi%(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.get
}(%(py5)s
{%(py5)s = %(py3)s.session_id
})
} is %(py9)sstorer   )r   rA   r   r   r   rB   assert %(py11)spy11)r   createget
session_idr#   r$   r%   r&   r'   r(   r)   r*   )rL   r   rD   r,   r-   r/   rG   @py_format12s           r6   test_store_create_and_getrS       s   NNE&''A9'Q\'99\""'"a''''''''''"a''''''''''''5'''''5''''''9'''''''''''Q'''''Q''''''\''''"'''''''''''a'''''a'''''''''''''''''''''''''''''''''r8   c                    t                      } | j        }d} ||          }d }||u }|st          j        d|fd||f          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}}d S )NnonexistentrJ   )zI%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.get
}(%(py4)s)
} is %(py9)srL   )r   rA   r   r   rB   rM   rN   )
r   rP   r#   r$   r%   r&   r'   r(   r)   r*   )rL   rD   r3   rE   r/   @py_assert7rG   rR   s           r6   #test_store_get_missing_returns_nonerW   &   s-   NNE9+]+99]##+t+#t++++++++++#t++++++++++++5+++++5++++++9++++]++++#++++t+++++++++++++++++++++++++++++++++r8   c                    t                      } |                     d          }|                     |j        d          }||u }|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        |          rt	          j	        |          nddz  }dd|iz  }t          t	          j        |                    d }d S )	NtestrJ   )z%(py0)s is %(py2)ss2r   )r   rA   zassert %(py4)sr   )r   rO   get_or_createrQ   r#   r$   r%   r&   r'   r(   r)   r*   )rL   r   rZ   rD   @py_format3r4   s         r6   )test_store_get_or_create_returns_existingr]   +   s    NNEVA			Q\6	2	2B7NNNNNNNNN2NNNNNNNNNNNN2NNNNN2NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNr8   c                    t                      } |                     d d          }|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          |           }d}||k    }|st          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        |          dz  }	dd|	iz  }
t          t          j
        |
                    d x}x}}d S )NrY   r   )z,%(py2)s
{%(py2)s = %(py0)s.slug
} == %(py5)sr   )r   rA   r   zassert %(py7)sr   r   )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   rL   )r   r   r   r   zassert %(py8)spy8)r   r[   r	   r#   r$   r%   r&   r'   r(   r)   r*   r   )rL   r   rD   r,   r3   @py_format6rF   r+   rE   r5   @py_format9s              r6   /test_store_get_or_create_creates_new_if_missingrb   2   s   NNED&))A6V6V6V116Vu:::?:33uu:r8   c            	        t                      } |                     d          }|                     |j                   | j        }|j        } ||          }d }||u }|st          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	        |          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 S )	NrY   rJ   )zj%(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.get
}(%(py5)s
{%(py5)s = %(py3)s.session_id
})
} is %(py10)srL   r   )r   rA   r   r   r   r   r   r   )r   rO   deleterQ   rP   r#   r$   r%   r&   r'   r(   r)   r*   )	rL   r   rD   r,   r-   r.   r/   r0   r1   s	            r6   test_store_deletere   9   s   NNEVA	LL9*Q\*99\""*d*"d**********"d************5*****5******9***********Q*****Q******\****"****d*********************************r8   )__doc__
__future__r   builtinsr%   _pytest.assertion.rewrite	assertionrewriter#   runtime.conversation.sessionr   r   r7   r?   rH   rS   rW   r]   rb   re    r8   r6   <module>rn      s    0 0 " " " " " "               > > > > > > > >1 1 1! ! !  ( ( (, , ,
    + + + + +r8   