#!/usr/bin/env python
import os
import sys
import django

# Add the backend directory to the path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

# Setup Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
django.setup()

from igny8_core.modules.writer.models import Content
from igny8_core.modules.writer.serializers import ContentSerializer

print("Testing ContentSerializer tags and categories fields...")
print("=" * 60)

# Get a content record
content = Content.objects.first()
if content:
    serializer = ContentSerializer(content)
    data = serializer.data
    print(f"Content ID: {data['id']}")
    print(f"Title: {data.get('title', 'N/A')}")
    print(f"Tags: {data.get('tags', [])}")
    print(f"Categories: {data.get('categories', [])}")
    print(f"Taxonomy Terms Data: {len(data.get('taxonomy_terms_data', []))} items")
    
    # Show taxonomy terms breakdown
    taxonomy_terms = data.get('taxonomy_terms_data', [])
    if taxonomy_terms:
        print("\nTaxonomy Terms Details:")
        for term in taxonomy_terms:
            print(f"  - {term['name']} ({term['taxonomy_type']})")
    
    print("\n✓ Serializer fields test passed!")
else:
    print("No content found in database")
    print("This is expected if no content has been generated yet")

