06/16 Phase 6 (continue)
This commit is contained in:
+17
-5
@@ -10,7 +10,7 @@ import os
|
||||
import re
|
||||
import io
|
||||
import logging
|
||||
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
os.environ.setdefault("SECRET_KEY", "test-secret")
|
||||
@@ -20,6 +20,11 @@ _SMOKE_DB = os.path.join(tempfile.gettempdir(), "classifieds_smoke.db")
|
||||
if os.path.exists(_SMOKE_DB):
|
||||
os.remove(_SMOKE_DB)
|
||||
os.environ.setdefault("DATABASE_URL", f"sqlite:///{_SMOKE_DB}")
|
||||
# Use a dedicated temp media dir so image counts are deterministic across runs.
|
||||
_SMOKE_MEDIA = os.path.join(tempfile.gettempdir(), "classifieds_smoke_media")
|
||||
if os.path.exists(_SMOKE_MEDIA):
|
||||
shutil.rmtree(_SMOKE_MEDIA)
|
||||
os.environ["MEDIA_ROOT"] = _SMOKE_MEDIA
|
||||
os.environ.setdefault("REDIS_URL", "memory://") # limiter in-memory
|
||||
os.environ.setdefault("FLASK_CONFIG", "dev")
|
||||
|
||||
@@ -273,7 +278,7 @@ def _phase4(app):
|
||||
user_fresh = db.session.get(User, user.id)
|
||||
assert user_fresh.role == Role.subscriber
|
||||
assert user_fresh.tier.slug == "pro"
|
||||
print("sync_subscription → user upgraded to pro subscriber: ok")
|
||||
print("sync_subscription -> user upgraded to pro subscriber: ok")
|
||||
|
||||
# --- downgrade to free ---
|
||||
bsvc.downgrade_to_free(user.id)
|
||||
@@ -659,7 +664,8 @@ def _phase6(app):
|
||||
login("t@example.com", "NewPass456")
|
||||
for path in ("/admin", "/admin/listings", "/admin/reports", "/admin/settings",
|
||||
"/admin/categories", "/admin/plans", "/admin/transactions",
|
||||
"/admin/audit"):
|
||||
"/admin/audit", "/admin/ads", "/admin/sponsors",
|
||||
"/admin/promoted-keywords", "/admin/analytics"):
|
||||
assert c.get(path, base_url=B).status_code == 403
|
||||
print("non-admin /admin* -> 403: ok")
|
||||
c.get("/auth/logout", base_url=B)
|
||||
@@ -674,7 +680,11 @@ def _phase6(app):
|
||||
"/admin/listings", "/admin/reports", "/admin/settings",
|
||||
"/admin/categories", f"/admin/categories/{cat_id}/schema",
|
||||
"/admin/plans", f"/admin/plans/{plan_id}",
|
||||
"/admin/transactions", "/admin/audit"):
|
||||
"/admin/transactions", "/admin/audit",
|
||||
"/admin/ads", "/admin/ads/new",
|
||||
"/admin/sponsors", "/admin/sponsors/new",
|
||||
"/admin/promoted-keywords", "/admin/promoted-keywords/new",
|
||||
"/admin/analytics"):
|
||||
code = c.get(path, base_url=B).status_code
|
||||
assert code == 200, f"{path} -> {code}"
|
||||
print(f"{code} {path}")
|
||||
@@ -993,7 +1003,9 @@ def _phase2(app):
|
||||
db.session.add(img); db.session.commit()
|
||||
assert img.path.endswith(".jpg") and img.thumb_path and img.width <= 1600
|
||||
import os
|
||||
media = os.path.join(app.instance_path, "media", str(l1.id))
|
||||
media_root = (app.config.get("MEDIA_ROOT")
|
||||
or os.path.join(app.instance_path, "media"))
|
||||
media = os.path.join(media_root, str(l1.id))
|
||||
assert os.path.isdir(media) and len(os.listdir(media)) == 2
|
||||
print("image pipeline (re-encode + thumbnail + EXIF strip): ok")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user