test: add platform API integration tests (67 tests)

Add comprehensive test coverage for platform marketing homepage API:
- test_pricing.py: 17 tests for tiers, add-ons, pricing endpoints
- test_letzshop_vendors.py: 22 tests for vendor lookup and claiming
- test_signup.py: 28 tests for multi-step signup flow

Fix signup.py to use correct password hashing from middleware/auth.py
and properly create Company with owner_user_id.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-27 12:44:39 +01:00
parent 0fca762b33
commit 83198df3e7
6 changed files with 1336 additions and 14 deletions

View File

@@ -267,30 +267,43 @@ async def create_account(
)
try:
# Create Company
# Create User first (needed for Company owner)
from middleware.auth import AuthManager
auth_manager = AuthManager()
# Generate username from email
username = request.email.split("@")[0]
base_username = username
counter = 1
while db.query(User).filter(User.username == username).first():
username = f"{base_username}_{counter}"
counter += 1
user = User(
email=request.email,
username=username,
hashed_password=auth_manager.hash_password(request.password),
first_name=request.first_name,
last_name=request.last_name,
role="vendor",
is_active=True,
)
db.add(user)
db.flush()
# Create Company (with owner)
from models.database.company import Company
company = Company(
name=request.company_name,
owner_user_id=user.id,
contact_email=request.email,
contact_phone=request.phone,
)
db.add(company)
db.flush()
# Create User
from app.core.security import get_password_hash
user = User(
email=request.email,
hashed_password=get_password_hash(request.password),
first_name=request.first_name,
last_name=request.last_name,
is_active=True,
)
db.add(user)
db.flush()
# Generate vendor code
vendor_code = request.company_name.upper().replace(" ", "_")[:20]
# Ensure unique