winofy-backend/apps/stores/tests/test_seller_store.py
Ali Asadi 52adc732fa Initial Winofy backend: marketplace core (no payment integration)
Django 6 + DRF resource server against the Gooyal accounts OAuth2 service,
matching the Winsoo ecosystem's conventions. Covers locations, stores,
catalog, cart, checkout/orders (with the multi-store-cart split and the
status stepper), reviews, and notifications, plus a demo-data seed command.

Payment integration (wallet debits, online gateway, seller payouts) is
intentionally left out here — see feature/payment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 14:03:15 +03:30

39 lines
1.6 KiB
Python

import uuid
from apps.locations.models import City
from apps.stores.models import Store, StoreCategory
from apps.users.models import User
from apps.orders.tests.base import OrdersTestCase
class SellerStoreTests(OrdersTestCase):
def setUp(self):
self.new_seller = User.objects.create_user(pk=uuid.uuid4(), username='new_seller')
self.category = StoreCategory.objects.create(name='کافه')
def test_seller_can_create_their_store(self):
self.client.force_authenticate(user=self.new_seller)
response = self.client.post('/api/v1/seller/store/', {
'name': 'کافه من',
'category_uuid': str(self.category.uuid),
'city_uuid': str(self.city.uuid),
'address': 'خیابان ولیعصر',
})
self.assertEqual(response.status_code, 201, response.data)
self.assertTrue(Store.objects.filter(owner=self.new_seller).exists())
def test_seller_cannot_create_a_second_store(self):
self.client.force_authenticate(user=self.seller1)
response = self.client.post('/api/v1/seller/store/', {
'name': 'فروشگاه دوم',
'category_uuid': str(self.category.uuid),
'city_uuid': str(self.city.uuid),
'address': 'خیابان دیگر',
})
self.assertEqual(response.status_code, 409)
def test_non_seller_cannot_access_seller_endpoints(self):
self.client.force_authenticate(user=self.customer)
response = self.client.get('/api/v1/seller/store/')
self.assertEqual(response.status_code, 404) # no store yet -> get_object_or_404