bugfix getallapps

This commit is contained in:
2024-12-17 19:56:29 +09:00
parent 51e15287f5
commit c2a7ead1e3
9 changed files with 121 additions and 40 deletions

View File

@@ -70,7 +70,7 @@ def password():
return "password"
@pytest.fixture(scope="session")
def user(password,test_tenant_id):
def user(test_db,password,test_tenant_id):
user = models.User(
email = "user@test.com",
first_name = "user",
@@ -80,10 +80,13 @@ def user(password,test_tenant_id):
is_superuser = False,
tenantid = test_tenant_id
)
return user
test_db.add(user)
test_db.commit()
test_db.refresh(user)
return user.__dict__
@pytest.fixture(scope="session")
def admin(password,test_tenant_id):
def admin(test_db,password,test_tenant_id):
user = models.User(
email = "admin@test.com",
first_name = "admin",
@@ -93,22 +96,25 @@ def admin(password,test_tenant_id):
is_superuser = True,
tenantid =test_tenant_id
)
return user
@pytest.fixture(scope="session")
def login_user(test_db,test_client,user,password):
test_db.add(user)
test_db.commit()
test_db.refresh(user)
response = test_client.post("/api/token", data={"username": user.email, "password":password })
return user.__dict__
@pytest.fixture(scope="session")
def login_user(test_db,test_client,user,password):
# test_db.add(user)
# test_db.commit()
#test_db.refresh(user)
response = test_client.post("/api/token", data={"username": user["email"], "password":password })
return response.json()["access_token"]
@pytest.fixture(scope="session")
def login_admin(test_db,test_client,admin,password):
test_db.add(admin)
test_db.commit()
test_db.refresh(admin)
response = test_client.post("/api/token", data={"username": admin.email, "password":password })
# test_db.add(admin)
# test_db.commit()
#test_db.refresh(admin)
response = test_client.post("/api/token", data={"username": admin["email"], "password":password })
return response.json()["access_token"]
@pytest.fixture(scope="session")