Invoice %RandomInvoiceNumber%

Dear %FirstName% %LastName%,

Your invoice %RandomInvoiceNumber% for %RandomTotal% (shipping %RandomShippingCharge%) is due on %DueDate%.

Company: %CompanyName% · Phone: %CompanyPhone%

Prefer plain text? The plain-text alternative is attached automatically.

Unsubscribe

""" async def main(): async with AsyncSessionLocal() as db: user = (await db.execute(select(User).where(User.email == DEMO_EMAIL))).scalar_one_or_none() if not user: print(f"ERROR: user {DEMO_EMAIL} not found — register it first") return # clean previous demo rows for T in (SubjectLine, EmailTemplate): for row in (await db.execute(select(T).where(T.user_id == user.id))).scalars(): await db.delete(row) accs = (await db.execute(select(GmailAccount).where(GmailAccount.user_id == user.id))).scalars().all() for a in accs: await db.delete(a) await db.commit() for s in SUBJECTS: db.add(SubjectLine(user_id=user.id, subject=s)) db.add(EmailTemplate(user_id=user.id, name="QA Invoice — blue", subject_hint="Invoice %RandomInvoiceNumber% for %CompanyName%", body_html=TPL_HTML)) acc = GmailAccount(user_id=user.id, email="qa.bot.sender@gmail.com", status="authorized", sending_method="api", is_active=True, daily_limit=200, campaign_limit=200) db.add(acc) await db.commit() db.add(OAuthToken(account_id=acc.id, access_token="fake-token-for-local-qa", refresh_token="fake-refresh", expires_at=datetime.now(timezone.utc) + timedelta(hours=2))) await db.commit() counts = {} counts["subjects"] = (await db.execute(select(SubjectLine).where(SubjectLine.user_id == user.id))).scalars() counts["templates"] = (await db.execute(select(EmailTemplate).where(EmailTemplate.user_id == user.id))).scalars() counts["accounts"] = (await db.execute(select(GmailAccount).where(GmailAccount.user_id == user.id))).scalars() print("Seeded for", DEMO_EMAIL, "| subjects:", len(list(counts["subjects"])), "| templates:", len(list(counts["templates"])), "| accounts:", len(list(counts["accounts"]))) if __name__ == "__main__": asyncio.run(main())