File size: 765 Bytes
d488241 |
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 |
import pytest
from app.models import User, Ad, AdVersion
from app import db
@pytest.fixture
def test_user():
user = User(email="test@example.com")
user.set_password("password123")
return user
@pytest.fixture
def test_ad(test_user):
return Ad(content="Test ad content", user_id=test_user.id)
def test_user_creation(test_user):
assert test_user.email == "test@example.com"
assert test_user.check_password("password123")
def test_ad_creation(test_ad):
assert test_ad.content == "Test ad content"
assert test_ad.user_id is not None
def test_ad_version_creation(test_ad):
version = AdVersion(content="Updated ad content", ad_id=test_ad.id)
assert version.content == "Updated ad content"
assert version.ad_id == test_ad.id |