add tenant logic

This commit is contained in:
2024-12-15 12:28:22 +09:00
parent 2823364148
commit 39775a5179
16 changed files with 138 additions and 55 deletions

View File

@@ -5,7 +5,7 @@ from fastapi.testclient import TestClient
import typing as t
from app.core import config, security
from app.db.session import Base, get_db
from app.core.dbmanager import get_db
from app.db import models,schemas
from app.main import app
@@ -42,9 +42,12 @@ def test_client(test_db):
with TestClient(app) as test_client:
yield test_client
@pytest.fixture(scope="session")
def test_tenant_id():
return "1"
@pytest.fixture(scope="session")
def test_user(test_db):
def test_user(test_db,test_tenant_id):
password ="test"
user = models.User(
email = "test@test.com",
@@ -52,7 +55,8 @@ def test_user(test_db):
last_name = "abc",
hashed_password = security.get_password_hash(password),
is_active = True,
is_superuser = False
is_superuser = False,
tenantid = test_tenant_id
)
test_db.add(user)
test_db.commit()
@@ -66,26 +70,28 @@ def password():
return "password"
@pytest.fixture(scope="session")
def user(password):
def user(password,test_tenant_id):
user = models.User(
email = "user@test.com",
first_name = "user",
last_name = "abc",
hashed_password = security.get_password_hash(password),
is_active = True,
is_superuser = False
is_superuser = False,
tenantid = test_tenant_id
)
return user
@pytest.fixture(scope="session")
def admin(password):
def admin(password,test_tenant_id):
user = models.User(
email = "admin@test.com",
first_name = "admin",
last_name = "abc",
hashed_password = security.get_password_hash(password),
is_active = True,
is_superuser = True
is_superuser = True,
tenantid =test_tenant_id
)
return user