
    fV                     p    d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZ ddlmZ  G d d	ee      Zy
)    )parse_qsurlparse)reverse)	urlencode)OAuth2TestsMixin)MockedResponseTestCasemocked_response   )NotionProviderc                   D    e Zd Zej                  ZdZd Zd ZddZ	ddZ
y)	NotionTestsFc                     t        dd      S )N   a  
            {
                "workspace_id": "workspace-abc",
                "workspace_name": "My Workspace",
                "owner": {
                    "user": {
                        "id": "test123",
                        "name": "John Doe",
                        "avatar_url": "",
                        "person": {"email": "john@example.com"},
                    }
                },
            }
            )r   selfs    g/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/allauth/socialaccount/providers/notion/tests.pyget_mocked_responsezNotionTests.get_mocked_response   s    
 	
    c                      y)NzJohn Doe (My Workspace) r   s    r   get_expected_to_strzNotionTests.get_expected_to_str#   s    (r   c                      y)z
        Docs here:
        https://developers.notion.com/docs/authorization#step-4-notion-responds-with-an-access_token-and-additional-information
        a  
        {
            "access_token": "testac",
            "bot_id": "bot-abc",
            "duplicated_template_id": "template-abc",
            "owner": {
            "workspace_id": "workspace-abc",
                "user": {
                    "id": "test123",
                    "name": "John Doe",
                    "avatar_url": "",
                    "person": {
                        "email": "john@example.com"
                    }
                }
            },
            "workspace_icon": "https://example.com/icon.png",
            "workspace_id": "workspace-abc",
            "workspace_name": "My Workspace"
        }
        r   )r   with_refresh_tokens     r   get_login_response_jsonz#NotionTests.get_login_response_json&   s    
r   Nc                 F   | j                   j                  t        | j                  j                  dz         dz   t        t        |            z         }t        |d         }t        |j                        }t        | j                  j                  dz         }| j                  |      }t        |t              r|}	n|g }	n|g}	t        t        d|dd	i      g|	 5  | j                   j                  || j!                  |            }d d d        |S # 1 sw Y   |S xY w)
N_login?)processlocation	_callback)r   r   zcontent-typezapplication/json)clientpostr   provideridr   dictr   r   queryr   
isinstancelistr
   r   getget_complete_parameters)
r   	resp_mockr   r   resppqcomplete_urlresponse_json
resp_mockss
             r   loginzNotionTests.loginA   s   {{DMM$$x/0W-./
 T*%&QWWt}}//+=>441 5 
 i&"JJ#J3@R/ST

 	R ;;??<1M1Ma1PQD		R 	R s    ,DD )F)Nr3   T)__name__
__module____qualname__r   r%   provider_idpkce_enabled_defaultr   r   r   r3   r   r   r   r   r      s'     ##K 
&)6r   r   N)urllib.parser   r   django.urlsr   django.utils.httpr   allauth.socialaccount.testsr   allauth.testsr   r	   r
   r$   r   r   r   r   r   <module>r>      s+    +  ' 8 C C $Q"H Qr   