🔥 refactor(user/utils.py): remove unused code and imports from user/utils.py module

✨ feat(test_api_key.py): add tests for API key creation, retrieval, and deletion
✨ feat(test_user.py): remove unused fixtures and imports from test_user.py module
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-25 12:05:54 -03:00
commit 950b9d179b
4 changed files with 88 additions and 89 deletions

View file

@ -4,42 +4,7 @@ from langflow.services.auth.utils import create_super_user, get_password_hash
from langflow.services.database.models.user.user import User
from langflow.services.utils import get_settings_manager
import pytest
from langflow.services.database.models.user import UserCreate, UserUpdate
@pytest.fixture
def test_user(client):
user_data = UserCreate(
username="testuser",
password="testpassword",
)
response = client.post("/api/v1/user", json=user_data.dict())
return response.json()
@pytest.fixture(scope="function")
def active_user(session):
user = User(
username="activeuser",
password=get_password_hash(
"testpassword"
), # Assuming password needs to be hashed
is_active=True,
is_superuser=False,
)
session.add(user)
session.commit()
return user
@pytest.fixture
def logged_in_headers(client, active_user):
login_data = {"username": active_user.username, "password": "testpassword"}
response = client.post("/api/v1/login", data=login_data)
assert response.status_code == 200
tokens = response.json()
a_token = tokens["access_token"]
return {"Authorization": f"Bearer {a_token}"}
from langflow.services.database.models.user import UserUpdate
@pytest.fixture