
    )Jf
                     x    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d
S )    )parse_qsurlparse)reverse)	urlencode)OAuth2TestsMixin)MockedResponseTestCasemocked_response   )NotionProviderc                   6    e Zd Zej        ZdZd ZddZd	dZ	dS )
NotionTestsFc                 "    t          dd          S )N   a|  
            {
                "workspace_id": "workspace-abc",
                "owner": {
                    "user": {
                        "id": "test123",
                        "name": "John Doe",
                        "avatar_url": "",
                        "person": {"email": "john@example.com"},
                    }
                },
            }
            )r   )selfs    o/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/providers/notion/tests.pyget_mocked_responsezNotionTests.get_mocked_response   s    
 
 	
    c                     dS )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   with_refresh_tokens     r   get_login_response_jsonz#NotionTests.get_login_response_json"   s    
 r   NloginTc                 n   | j                             t          | j        j        dz             dz   t          t          |                    z             }t          |d                   }t          |j	                  }t          | j        j        dz             }| 
                    |          }t          |t                    r|}	n|g }	n|g}	t          t          d|dd	i          g|	R  5  | j                             ||                     |                    }d d d            n# 1 swxY w Y   |S )
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   r   zNotionTests.login=   s   {DM$x/00W---../
 
 T*%&&QWt}/+=>>441 5 
 
 i&& 	%"JJJJ#J3@R/STT

 
 
 	R 	R ;??<1M1Ma1P1PQQD		R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R s   //D**D.1D.)F)Nr   T)
__name__
__module____qualname__r   r#   provider_idpkce_enabled_defaultr   r   r   r   r   r   r   r      sY         #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 8 8 8 8 8 C C C C C C C C C C $ $ $ $ $ $M M M M M"H M M M M Mr   