Spaces:
Runtime error
Runtime error
File size: 847 Bytes
66340f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from uuid import uuid4
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.document import Document
from app.models.user import User
import random
import string
def generate_random_string():
characters = string.ascii_letters + string.digits
random_string = "".join(random.choice(characters) for _ in range(4))
return random_string
def generate_random_3digit_int():
return int(random.randint(100, 999))
async def test_document_model(db: AsyncSession):
user_id = uuid4()
user = User(
id=user_id,
email=generate_random_string() + "@exampsadfle.com",
hashed_password="12sdf34",
)
document = Document(
id=generate_random_3digit_int(), user_id=user_id, name="Impact_of_tech.pdf"
)
db.add(user)
db.add(document)
await db.commit()
assert document.id
|