o
    "4g
                     @   sf   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ G d	d
 d
ee	ZdS )z{
    Run just this suite:
    python manage.py test allauth.socialaccount.providers.trainingpeaks.tests.TrainingPeaksTests
    )
namedtuple)override_settings)OAuth2TestsMixin)MockedResponseTestCase   )TrainingPeaksProvider)TrainingPeaksOAuth2Adapterc                   @   st   e Zd ZejZdd Zdd ZdddZdd	 Z	e
d
ddiiddd Zdd Ze
d
dg diiddd ZdS )TrainingPeaksTestsc                 C   s
   t ddS )N   a(  {
                "Id": 123456,
                "FirstName": "John",
                "LastName": "Doe",
                "Email": "user@example.com",
                "DateOfBirth": "1986-02-01T00:00:00",
                "CoachedBy": 987654,
                "Weight": 87.5223617553711
            })r   self r   |/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/trainingpeaks/tests.pyget_mocked_response   s   z&TrainingPeaksTests.get_mocked_responsec                 C   s   dS )Nzuser@example.comr   r   r   r   r   get_expected_to_str"   s   z&TrainingPeaksTests.get_expected_to_strTc                 C   s   d}|rd}d| S )N z,"refresh_token": "testrf"z{
                "access_token" : "testac",
                "token_type" : "bearer",
                "expires_in" : 600,
                "scope": "scopes granted"
            %s }r   )r   with_refresh_tokenrtokenr   r   r   get_login_response_json%   s   z*TrainingPeaksTests.get_login_response_jsonc                 C   <   t d }| d|jv  | d|jv  | d|jv  d S Nz	.sandbox.)r	   
assertTrueauthorize_urlaccess_token_urlprofile_urlr   adapterr   r   r   test_default_use_sandbox_uri3   s   z/TrainingPeaksTests.test_default_use_sandbox_uritrainingpeaksUSE_PRODUCTION)SOCIALACCOUNT_PROVIDERSc                 C   r   r   )r	   assertFalser   r   r   r   r   r   r   test_use_production_uri9   s   z*TrainingPeaksTests.test_use_production_uric                 C   s4   t ddg}|i d}| j|}| d|v  d S )NrequestGETr%   athlete:profiler   providerget_scope_from_requestr   )r   Requestmock_requestscoper   r   r   test_scope_from_defaultB   s   
z*TrainingPeaksTests.test_scope_from_defaultSCOPEr'   workoutszworkouts:wodc                 C   s>   t ddg}|i d}| j|}dD ]	}| ||v  qd S )Nr$   r%   r&   r0   r(   )r   r+   r,   r-   itemr   r   r   test_scope_from_settingsH   s   
z+TrainingPeaksTests.test_scope_from_settingsN)T)__name__
__module____qualname__r   idprovider_idr   r   r   r   r   r#   r.   r3   r   r   r   r   r
      s     


r
   N)__doc__collectionsr   django.test.utilsr   allauth.socialaccount.testsr   allauth.testsr   r   r)   r   viewsr	   r
   r   r   r   r   <module>   s    