You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
#!/usr/bin/env python
|
|
import os
|
|
import sys
|
|
import django
|
|
from pathlib import Path
|
|
|
|
# Set up Django environment manually
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
|
|
try:
|
|
# Try to avoid the environ import issue
|
|
import importlib
|
|
sys.modules['environ'] = importlib.util.spec_from_loader('environ', None)
|
|
|
|
from django.conf import settings
|
|
if not settings.configured:
|
|
settings.configure(
|
|
DATABASES={
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': 'imam_javad_db',
|
|
'USER': 'postgres',
|
|
'PASSWORD': '123456789',
|
|
'HOST': 'localhost',
|
|
'PORT': '5432',
|
|
}
|
|
},
|
|
INSTALLED_APPS=[
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.auth',
|
|
'apps.hadis',
|
|
],
|
|
USE_TZ=True,
|
|
SECRET_KEY='temp-key-for-test',
|
|
)
|
|
|
|
django.setup()
|
|
|
|
from apps.hadis.models import Transmitters
|
|
from apps.hadis.serializers.hadis import TransmitterDetailSerializer
|
|
|
|
transmitter = Transmitters.objects.first()
|
|
if transmitter:
|
|
serializer = TransmitterDetailSerializer(transmitter)
|
|
data = serializer.data
|
|
print('✓ Serializer works!')
|
|
print(f'Has opinions field: {"opinions" in data}')
|
|
print(f'Has hadis_transmissions field: {"hadis_transmissions" in data}')
|
|
if 'opinions' in data:
|
|
print(f'Opinions count: {len(data["opinions"])}')
|
|
if 'hadis_transmissions' in data:
|
|
print(f'Hadis transmissions count: {len(data["hadis_transmissions"])}')
|
|
print('Test completed successfully!')
|
|
else:
|
|
print('No transmitters found')
|
|
|
|
except Exception as e:
|
|
print(f'✗ Error: {e}')
|
|
import traceback
|
|
traceback.print_exc()
|