Skip to content

Commit 3d6ef7e

Browse files
author
Peng Ren
committed
Fixed test case issue
1 parent 3f630cd commit 3d6ef7e

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
from pymongosql.connection import Connection
77

8+
# Silence SQLAlchemy 1.4 deprecation warnings in tests
9+
os.environ.setdefault("SQLALCHEMY_SILENCE_UBER_WARNING", "1")
10+
811
# Centralized test configuration sourced from environment to allow running tests
912
# against remote MongoDB (e.g. Atlas) or local test instance.
1013
TEST_URI = os.environ.get("PYMONGOSQL_TEST_URI") or os.environ.get("MONGODB_URI")

tests/test_sqlalchemy_dml.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# ORM Models for testing
1616
if HAS_SQLALCHEMY:
1717

18-
class TestUser(Base):
19-
"""Test user model for DML operations."""
18+
class User(Base):
19+
"""User model for DML operations testing."""
2020

2121
__tablename__ = "test_users_orm"
2222

@@ -26,8 +26,8 @@ class TestUser(Base):
2626
age = Column(Integer)
2727
is_active = Column(Boolean, default=True)
2828

29-
class TestProduct(Base):
30-
"""Test product model for DML operations."""
29+
class Product(Base):
30+
"""Product model for DML operations testing."""
3131

3232
__tablename__ = "test_products_orm"
3333

@@ -478,7 +478,7 @@ def test_orm_insert_single_object(self, session_maker, conn):
478478
session.commit()
479479

480480
# Create and insert a user using pure ORM
481-
user = TestUser()
481+
user = User()
482482
user.id = 100
483483
user.name = "John Doe"
484484
user.email = "john@example.com"
@@ -523,7 +523,7 @@ def test_orm_insert_multiple_objects_individually(self, session_maker, conn):
523523
session.commit()
524524

525525
# Create and insert products using pure ORM - add individually
526-
product1 = TestProduct()
526+
product1 = Product()
527527
product1.id = 200
528528
product1.name = "Laptop"
529529
product1.price = 999.99
@@ -532,7 +532,7 @@ def test_orm_insert_multiple_objects_individually(self, session_maker, conn):
532532
session.add(product1)
533533
session.commit()
534534

535-
product2 = TestProduct()
535+
product2 = Product()
536536
product2.id = 201
537537
product2.name = "Mouse"
538538
product2.price = 25.50
@@ -541,7 +541,7 @@ def test_orm_insert_multiple_objects_individually(self, session_maker, conn):
541541
session.add(product2)
542542
session.commit()
543543

544-
product3 = TestProduct()
544+
product3 = Product()
545545
product3.id = 202
546546
product3.name = "Keyboard"
547547
product3.price = 75.00
@@ -589,7 +589,7 @@ def test_orm_update_via_raw_sql(self, session_maker, conn):
589589
session.commit()
590590

591591
# Create and insert initial user using ORM
592-
user = TestUser()
592+
user = User()
593593
user.id = 300
594594
user.name = "Jane Smith"
595595
user.email = "jane@example.com"
@@ -638,7 +638,7 @@ def test_orm_delete_via_raw_sql(self, session_maker, conn):
638638
session.commit()
639639

640640
# Create and insert products using ORM
641-
product1 = TestProduct()
641+
product1 = Product()
642642
product1.id = 400
643643
product1.name = "Monitor"
644644
product1.price = 299.99
@@ -647,7 +647,7 @@ def test_orm_delete_via_raw_sql(self, session_maker, conn):
647647
session.add(product1)
648648
session.commit()
649649

650-
product2 = TestProduct()
650+
product2 = Product()
651651
product2.id = 401
652652
product2.name = "Speaker"
653653
product2.price = 49.99

0 commit comments

Comments
 (0)