from django.test import RequestFactory
from hotelfinder.restaurant.views import RestaurantListCreateView
from django.contrib.auth import get_user_model
import json

User = get_user_model()
admin_user = User.objects.filter(is_superuser=True).first() or User.objects.first()

factory = RequestFactory()
data = {
    "name": "Apna Garam Dharam Restaurant",
    "location": "Unknown City",
    "cuisine": "Various",
    "address": "",
    "is_active": True
}
request = factory.post('/api/restaurants/', data, content_type='application/json')
request.user = admin_user

view = RestaurantListCreateView.as_view()
response = view(request)
print("Status:", response.status_code)
print("Data:", response.data)
