Files
service-finder/tests/archive/patch_test.py.old

42 lines
1.9 KiB
Python

with open("backend/test_invitation_e2e.py", "r") as f:
code = f.read()
# Eltávolítjuk a delete részt
code = code.replace(""" emails = ["owner@test.com", "existing@test.com", "newbie@test.com", "shadow@test.com"]
for email in emails:
stmt = select(User).where(User.email == email)
user = (await db.execute(stmt)).scalar_one_or_none()
if user:
await db.delete(user)
shadow_person_stmt = select(Person).where(Person.last_name == "ShadowBéla")
for p in (await db.execute(shadow_person_stmt)).scalars():
await db.delete(p)
# Töröljük a korábbi tokeneket, amik a newbie@test.com-ra szólnak
stmt_token = select(VerificationToken).where(VerificationToken.token_type == "org_invite")
for t in (await db.execute(stmt_token)).scalars():
if t.extra_data and t.extra_data.get("email") == "newbie@test.com":
await db.delete(t)
await db.commit()""", "")
# Használjunk UUID-t az email címekhez
code = code.replace("owner@test.com", f"owner_{uuid.uuid4().hex[:6]}@test.com")
code = code.replace("existing@test.com", f"existing_{uuid.uuid4().hex[:6]}@test.com")
code = code.replace("newbie@test.com", f"newbie_{uuid.uuid4().hex[:6]}@test.com")
code = code.replace("shadow@test.com", f"shadow_{uuid.uuid4().hex[:6]}@test.com")
code = code.replace("ShadowBéla", f"ShadowBéla_{uuid.uuid4().hex[:6]}")
# Fájl mentése UUID generálással
import uuid
random_suffix = uuid.uuid4().hex[:6]
code = code.replace("owner_", f"owner_{random_suffix}_")
code = code.replace("existing_", f"existing_{random_suffix}_")
code = code.replace("newbie_", f"newbie_{random_suffix}_")
code = code.replace("shadow_", f"shadow_{random_suffix}_")
code = code.replace("ShadowBéla_", f"ShadowBéla_{random_suffix}_")
with open("backend/test_invitation_e2e.py", "w") as f:
f.write("import uuid\n" + code)