
    jKj_                     0    d Z ddlZ G d d      Zd Zd Zy)zShared test helpers for the posthog.mcp suite.

Kept in one place (OnceAndOnlyOnce) so the fake client and the fire-and-forget
flush logic can't drift between the FastMCP, low-level, PostHogMCP, and M4 tests.
    Nc                   &    e Zd ZdZd Z	 	 	 	 ddZy)
FakeClientz0Records capture() calls instead of sending them.c                     g | _         y )N)events)selfs    j/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/posthog/test/mcp/_helpers.py__init__zFakeClient.__init__   s	        Nc                 J    | j                   j                  |||xs i d       y )N)eventdistinct_id
properties)r   append)r   r   r   r   	timestampuuidkwargss          r   capturezFakeClient.capture   s+     	KzGWUWX	
 r
   )NNNN)__name__
__module____qualname____doc__r	   r    r
   r   r   r   
   s    : r
   r   c                  n  K   ddl mc m}  t        d      D ]r  }t	        j
                  d       d{    t        | j                        D cg c]  }|j                         r| }}|sVt	        j                  |ddi d{    t t	        j
                  d       d{    y7 wc c}w 7 +7 w)z4Let fire-and-forget capture tasks run to completion.r   N
   return_exceptionsT)
posthog.mcp._instrumentationmcp_instrumentationrangeasynciosleeplist_BACKGROUND_TASKSdonegather)instr_tpendings       r   flush_backgroundr*      s     002YmmA"5#:#:;L;16681;L..'BTBBB	 
 --
	 	LBsK   0B5B*B5B,$B,(B5-B5B1B5$B3%B5,B53B5c                 r    t        | d      r| j                  n| }|D cg c]  }|d   |k(  s| c}S c c}w )zCaptured events with the given name. ``source`` may be a ``FakeClient``
    (reads ``.events``) or a raw list of event dicts (PostHogMCP tests).r   r   )hasattrr   )sourcenamer   es       r   events_namedr0   +   s;     &fh7V]]VF4v!7t!3Av444s   44)r   r    r   r*   r0   r   r
   r   <module>r1      s#     *	5r
   