
    Di	                    r    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ  G d	 d
e      Zy)z6Tests for the /me/ and /me/wallets/ profile endpoints.    )annotations)Decimal)TestCase)reverse)status)	APIClient)Userc                  $    e Zd Zd Zd Zd Zd Zy)MeViewSetTestsc           	         t               | _        t        j                  j	                  dddt        d      t        d            | _        | j                  j                  | j                         y )Ni90  aliceAlice100.5000000010.25000000)telegram_user_idusername
first_namecredit_balancebonus_balanceuser)r   clientr	   objectscreate_userr   r   force_authenticate)selfs    O/home/cursorai/projects/telegram-earn/backend/apps/users/tests/test_me_views.pysetUpzMeViewSetTests.setUp   sZ    kLL,,"">2!-0 - 
	 	&&DII&6    c                   t        d      }| j                  j                  |      }| j                  |j                  t
        j                         |j                         }| j                  |d   d       | j                  |d   d       | j                  t        |d         t        d             | j                  t        |d         t        d	             y
)z<GET /api/users/me/ returns the authenticated user's profile.me-listr   r   r   r   r   r   r   r   N)	r   r   getassertEqualstatus_coder   HTTP_200_OKjsonr   )r   urlresponsedatas       r   test_get_me_profilez"MeViewSetTests.test_get_me_profile   s    i ;;??3'--v/A/AB}}j)73l+W5&6!78'.:QRo!679OPr   c                2   t        d      }| j                  j                  |      }| j                  |j                  t
        j                         |j                         }| j                  t        |      d       t        d |D              }| j                  |d   d       | j                  t        |d         t        d             t        d |D              }| j                  |d   d	       | j                  t        |d         t        d
             y)z7GET /api/users/me/wallets/ returns all wallet balances.z
me-wallets   c              3  2   K   | ]  }|d    dk(  s|  yw)typer   N .0ws     r   	<genexpr>z5MeViewSetTests.test_get_me_wallets.<locals>.<genexpr>1   s     H$Q!F)7G*Gq$   namePrimarybalancer   c              3  2   K   | ]  }|d    dk(  s|  yw)r.   bonusNr/   r0   s     r   r3   z5MeViewSetTests.test_get_me_wallets.<locals>.<genexpr>6   s     =1&	W(<Qr4   Bonusr   N)r   r   r"   r#   r$   r   r%   r&   lennextr   )r   r'   r(   r)   primaryr9   s         r   test_get_me_walletsz"MeViewSetTests.test_get_me_wallets'   s    l#;;??3'--v/A/AB}}TA& H$HH)4!34gn6MN ===v0y!12GM4JKr   c                    | j                   j                  d       t        d      }| j                   j                  |      }| j	                  |j
                  t        j                         y)z)Requests without auth should be rejected.Nr   r!   )r   r   r   r"   r#   r$   r   HTTP_401_UNAUTHORIZED)r   r'   r(   s      r   test_get_me_unauthenticatedz*MeViewSetTests.test_get_me_unauthenticated:   sO    &&D&1i ;;??3'--v/K/KLr   N)__name__
__module____qualname__r   r*   r>   rA   r/   r   r   r   r      s    	7
QL&Mr   r   N)__doc__
__future__r   decimalr   django.testr   django.urlsr   rest_frameworkr   rest_framework.testr   apps.users.modelsr	   r   r/   r   r   <module>rM      s+    < "     ! ) "0MX 0Mr   