Update datetime handling in ApiKey and Variable models (#1673)

* Update datetime handling in ApiKey and Variable models

* Refactor test_login_successful function in test_login.py

* Fix nullable attribute for created_at and updated_at fields in Variable model
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-04-10 23:04:10 -03:00 • committed by GitHub
commit 836ac08d80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 24 additions and 18 deletions

View file

@ -1,8 +1,8 @@
import pytest
from langflow.services.auth.utils import get_password_hash
from langflow.services.database.models.user import User
from langflow.services.database.utils import session_getter
from langflow.services.deps import get_db_service
from langflow.services.deps import session_scope
from sqlalchemy.exc import IntegrityError
@pytest.fixture
@ -17,9 +17,12 @@ def test_user():
def test_login_successful(client, test_user):
# Adding the test user to the database
with session_getter(get_db_service()) as session:
session.add(test_user)
session.commit()
try:
with session_scope() as session:
session.add(test_user)
session.commit()
except IntegrityError:
pass
response = client.post("api/v1/login", data={"username": "testuser", "password": "testpassword"})
assert response.status_code == 200