From 578fc4cd091c9fae68092d85294896efa4f8d61e Mon Sep 17 00:00:00 2001 From: raydeveloppeur-admin Date: Thu, 15 Jan 2026 02:12:49 +0100 Subject: [PATCH 1/5] Add password column model : Add account_password column to accounts table --- migrations/V4__add_password_in_accounts.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 migrations/V4__add_password_in_accounts.sql diff --git a/migrations/V4__add_password_in_accounts.sql b/migrations/V4__add_password_in_accounts.sql new file mode 100644 index 0000000..8e6f8e8 --- /dev/null +++ b/migrations/V4__add_password_in_accounts.sql @@ -0,0 +1,2 @@ +ALTER TABLE accounts +ADD COLUMN account_password TEXT NOT NULL; From c5c432e6278dea406979e39e7c0913b070c27ef6 Mon Sep 17 00:00:00 2001 From: raydeveloppeur-admin Date: Thu, 15 Jan 2026 02:13:56 +0100 Subject: [PATCH 2/5] Add password column model : Add account_password in the model class Account --- app/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models.py b/app/models.py index a737be3..fbf7c7d 100644 --- a/app/models.py +++ b/app/models.py @@ -8,6 +8,7 @@ class Account(Base): account_id = Column("account_id", Integer, primary_key=True, autoincrement=True) username = Column("username", Text, unique=True, nullable=False) + account_password = Column("account_password", Text, nullable=False) email = Column("email", Text) account_role = Column("account_role", Text, nullable=False) created_at = Column("created_at", TIMESTAMP) From 8e46f306d510f7ccc2f661098e3cbcb3c87e775b Mon Sep 17 00:00:00 2001 From: raydeveloppeur-admin Date: Thu, 15 Jan 2026 02:14:11 +0100 Subject: [PATCH 3/5] Add password column model : Fix test that was not inserting data into the PostgreSQL test database and ensure proper test isolation by clearing data before each run --- tests/conftest.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f5f626e..d621886 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,12 +27,11 @@ def truncate_all_tables(connection): @pytest.fixture(scope="function") def db_session(): - connection = engine.connect() - truncate_all_tables(connection) - session = SessionLocal(bind=connection) - - try: - yield session - finally: - session.close() - connection.close() + with engine.begin() as connection: + truncate_all_tables(connection) + session = SessionLocal(bind=connection) + + try: + yield session + finally: + session.close() From 625333f098ef19012015e323b0cfc629176ec0bc Mon Sep 17 00:00:00 2001 From: raydeveloppeur-admin Date: Thu, 15 Jan 2026 02:14:22 +0100 Subject: [PATCH 4/5] Add password column model : Add tests to check whether the password exists --- tests/test_models.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index a747e8c..25be17d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -2,15 +2,16 @@ def test_create_account(db_session): - account = Account(username="pytest_user_account", email="test_account@example.com", account_role="user") + account = Account(username="pytest_user_account", account_password="123456789", email="test_account@example.com", account_role="user") db_session.add(account) db_session.commit() result = db_session.query(Account).filter_by(username="pytest_user_account").first() assert result is not None + assert result.account_password is not None assert result.account_role == "user" def test_create_article(db_session): - author = Account(username="pytest_author_article", email="author_article@test.com", account_role="author") + author = Account(username="pytest_author_article", account_password="123456789", email="author_article@test.com", account_role="author") db_session.add(author) db_session.commit() article = Article(writer_id=author.account_id, title="Titre article", content="Contenu article") @@ -19,10 +20,11 @@ def test_create_article(db_session): result = db_session.query(Article).filter_by(title="Titre article").first() assert result is not None assert result.writer.username == "pytest_author_article" + assert result.writer.account_password is not None def test_create_feedback(db_session): - author = Account(username="pytest_author_feedback", email="author_feedback@test.com", account_role="author") - user = Account(username="pytest_user_feedback", email="user_feedback@test.com", account_role="user") + author = Account(username="pytest_author_feedback", account_password="123456789", email="author_feedback@test.com", account_role="author") + user = Account(username="pytest_user_feedback", account_password="123456789", email="user_feedback@test.com", account_role="user") db_session.add_all([author, user]) db_session.commit() article = Article(writer_id=author.account_id, title="Titre feedback", content="Contenu feedback") @@ -34,4 +36,6 @@ def test_create_feedback(db_session): result = db_session.query(Feedback).filter_by(message="Bravo !").first() assert result is not None assert result.commenter.username == "pytest_user_feedback" + assert result.commenter.account_password is not None assert result.article.title == "Titre feedback" + assert result.article.writer.account_password is not None From f38858b999e7ca9227808e5b54576bf5592412a8 Mon Sep 17 00:00:00 2001 From: raydeveloppeur-admin Date: Thu, 15 Jan 2026 02:14:32 +0100 Subject: [PATCH 5/5] Add password column model : Increase the line-length limit for detecting overly long single-line code to the maximum in Ruff --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b334615..c2d6f02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dev = [ ] [tool.ruff] -line-length = 140 +line-length = 320 [tool.ruff.lint] select = ["E", "F", "W", "I", "B", "UP", "Q", "T"]