winofy-backend/apps/orders/tests/base.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

63 lines
2.8 KiB
Python

import uuid
from rest_framework.test import APITestCase
from apps.catalog.models import Product, ProductCategory
from apps.locations.models import Address, City, Neighborhood
from apps.stores.models import Store, StoreCategory
from apps.users.models import User
class OrdersTestCase(APITestCase):
@classmethod
def setUpTestData(cls):
cls.customer = User.objects.create_user(pk=uuid.uuid4(), username='customer1')
cls.seller1 = User.objects.create_user(pk=uuid.uuid4(), username='seller1')
cls.seller2 = User.objects.create_user(pk=uuid.uuid4(), username='seller2')
cls.city = City.objects.create(name='تهران', slug='tehran')
cls.neighborhood = Neighborhood.objects.create(city=cls.city, name='ونک', slug='vanak')
cls.other_neighborhood = Neighborhood.objects.create(city=cls.city, name='تجریش', slug='tajrish')
cls.address = Address.objects.create(
user=cls.customer,
city=cls.city,
neighborhood=cls.neighborhood,
full_address='خیابان ولیعصر',
recipient_name='مشتری تست',
recipient_phone='09120000000',
)
store_category = StoreCategory.objects.create(name='سوپرمارکت')
product_category = ProductCategory.objects.create(name='لبنیات')
cls.store1 = Store.objects.create(
owner=cls.seller1, category=store_category, name='فروشگاه یک',
city=cls.city, address='آدرس فروشگاه یک', status=Store.Status.APPROVED,
min_order_amount=10_000, delivery_fee=15_000, commission_percent=4,
)
cls.store1.service_neighborhoods.add(cls.neighborhood)
cls.store2 = Store.objects.create(
owner=cls.seller2, category=store_category, name='فروشگاه دو',
city=cls.city, address='آدرس فروشگاه دو', status=Store.Status.APPROVED,
min_order_amount=10_000, delivery_fee=20_000, commission_percent=4,
)
cls.store2.service_neighborhoods.add(cls.neighborhood)
cls.product1 = Product.objects.create(
store=cls.store1, category=product_category, name='شیر کاله',
price=28_500, stock_quantity=50,
)
cls.product2 = Product.objects.create(
store=cls.store2, category=product_category, name='پنیر لیقوان',
price=85_000, stock_quantity=50,
)
def add_to_cart(self, product, quantity=1):
return self.client.post('/api/v1/cart/items/', {'product_uuid': str(product.uuid), 'quantity': quantity})
def mock_external_clients(self):
"""No-op on this branch — payment integration (and its outbound Gooyal/ipg
calls) lives on feature/payment, not here."""
pass