This repository was archived by the owner on Jun 11, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathconftest.py
More file actions
55 lines (41 loc) · 1.43 KB
/
conftest.py
File metadata and controls
55 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import asyncio
from typing import Any, Dict, List, Optional
import pytest
from pydantic import UUID4
from sqlmodel import Field, Relationship
from fastapi_users_db_sqlmodel import SQLModelBaseOAuthAccount, SQLModelBaseUserDB
class User(SQLModelBaseUserDB, table=True):
first_name: Optional[str]
class UserOAuth(SQLModelBaseUserDB, table=True):
__tablename__ = "user_oauth"
oauth_accounts: List["OAuthAccount"] = Relationship(
back_populates="user",
sa_relationship_kwargs={"lazy": "selectin", "cascade": "all, delete"},
)
class OAuthAccount(SQLModelBaseOAuthAccount, table=True):
user_id: UUID4 = Field(foreign_key="user_oauth.id")
user: Optional[UserOAuth] = Relationship(back_populates="oauth_accounts")
@pytest.fixture(scope="session")
def event_loop():
"""Force the pytest-asyncio loop to be the main one."""
loop = asyncio.new_event_loop()
yield loop
loop.close()
@pytest.fixture
def oauth_account1() -> Dict[str, Any]:
return {
"oauth_name": "service1",
"access_token": "TOKEN",
"expires_at": 1579000751,
"account_id": "user_oauth1",
"account_email": "king.arthur@camelot.bt",
}
@pytest.fixture
def oauth_account2() -> Dict[str, Any]:
return {
"oauth_name": "service2",
"access_token": "TOKEN",
"expires_at": 1579000751,
"account_id": "user_oauth2",
"account_email": "king.arthur@camelot.bt",
}