Marketplace tests update
This commit is contained in:
@@ -9,7 +9,7 @@ This module provides classes and functions for:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -81,7 +81,7 @@ class AdminService:
|
||||
try:
|
||||
original_status = user.is_active
|
||||
user.is_active = not user.is_active
|
||||
user.updated_at = datetime.utcnow()
|
||||
user.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
|
||||
@@ -146,11 +146,11 @@ class AdminService:
|
||||
try:
|
||||
original_status = shop.is_verified
|
||||
shop.is_verified = not shop.is_verified
|
||||
shop.updated_at = datetime.utcnow()
|
||||
shop.updated_at = datetime.now(timezone.utc)
|
||||
|
||||
# Add verification timestamp if implementing audit trail
|
||||
if shop.is_verified:
|
||||
shop.verified_at = datetime.utcnow()
|
||||
shop.verified_at = datetime.now(timezone.utc)
|
||||
|
||||
db.commit()
|
||||
db.refresh(shop)
|
||||
@@ -190,7 +190,7 @@ class AdminService:
|
||||
try:
|
||||
original_status = shop.is_active
|
||||
shop.is_active = not shop.is_active
|
||||
shop.updated_at = datetime.utcnow()
|
||||
shop.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(shop)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ This module provides classes and functions for:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
|
||||
from sqlalchemy import func
|
||||
@@ -106,7 +106,7 @@ class MarketplaceService:
|
||||
shop_id=shop.id, # Foreign key to shops table
|
||||
shop_name=shop.shop_name, # Use shop.shop_name (the display name)
|
||||
user_id=user.id,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(timezone.utc),
|
||||
)
|
||||
|
||||
db.add(import_job)
|
||||
@@ -360,7 +360,7 @@ class MarketplaceService:
|
||||
raise ImportJobCannotBeCancelledException(job_id, job.status)
|
||||
|
||||
job.status = "cancelled"
|
||||
job.completed_at = datetime.utcnow()
|
||||
job.completed_at = datetime.now(timezone.utc)
|
||||
|
||||
db.commit()
|
||||
db.refresh(job)
|
||||
|
||||
@@ -10,7 +10,7 @@ This module provides classes and functions for:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import Generator, List, Optional, Tuple
|
||||
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
@@ -250,7 +250,7 @@ class ProductService:
|
||||
for key, value in update_data.items():
|
||||
setattr(product, key, value)
|
||||
|
||||
product.updated_at = datetime.utcnow()
|
||||
product.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(product)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ This module provides classes and functions for:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -68,7 +68,7 @@ class StockService:
|
||||
# Update existing stock (SET to exact quantity)
|
||||
old_quantity = existing_stock.quantity
|
||||
existing_stock.quantity = stock_data.quantity
|
||||
existing_stock.updated_at = datetime.utcnow()
|
||||
existing_stock.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(existing_stock)
|
||||
|
||||
@@ -128,7 +128,7 @@ class StockService:
|
||||
# Add to existing stock
|
||||
old_quantity = existing_stock.quantity
|
||||
existing_stock.quantity += stock_data.quantity
|
||||
existing_stock.updated_at = datetime.utcnow()
|
||||
existing_stock.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(existing_stock)
|
||||
|
||||
@@ -207,7 +207,7 @@ class StockService:
|
||||
raise NegativeStockException(normalized_gtin, location, new_quantity)
|
||||
|
||||
existing_stock.quantity = new_quantity
|
||||
existing_stock.updated_at = datetime.utcnow()
|
||||
existing_stock.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(existing_stock)
|
||||
|
||||
@@ -381,7 +381,7 @@ class StockService:
|
||||
self._validate_quantity(stock_update.quantity, allow_zero=True)
|
||||
|
||||
stock_entry.quantity = stock_update.quantity
|
||||
stock_entry.updated_at = datetime.utcnow()
|
||||
stock_entry.updated_at = datetime.now(timezone.utc)
|
||||
db.commit()
|
||||
db.refresh(stock_entry)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user