fb / app /tests /test_models.py
rastof9's picture
Saving local changes before rebase
d488241
raw
history blame contribute delete
765 Bytes
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