import pytest
from app.models import User, Folder
from app import db
import uuid
import conftest

def test_user_model(app,  mock_user):
    """Test User model creation and properties."""
    # Test user was created by fixture
    assert mock_user.email == 'test@example.com'
    
    # Test querying user
    user_from_db = User.query.filter_by(email='test@example.com').first()
    assert user_from_db is not None
    assert user_from_db.id == mock_user.id

def test_folder_model(app, mock_folder, mock_user):
    """Test Folder model creation and properties."""
    # Test folder was created by fixture
    assert mock_folder.user_id == mock_user.id
    assert mock_folder.name == 'Test Folder'
    assert mock_folder.rule_text == 'Test rule'
    assert mock_folder.priority == 1
    
    # Test relationship
    assert len(mock_user.folders) == 1
    assert mock_user.folders[0].id == mock_folder.id
    
    # Test querying folder
    folder_from_db = Folder.query.filter_by(name='Test Folder').first()
    assert folder_from_db is not None
    assert folder_from_db.user_id == mock_user.id