forked from erp-dev/erp
feat: added mdy stagging upload to tiia, and change outgoing_date to datetime type
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"""
|
||||
PrintingOrder API 测试
|
||||
"""
|
||||
from datetime import datetime
|
||||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from rest_framework.test import APIClient
|
||||
from rest_framework import status
|
||||
from django.contrib.auth import get_user_model
|
||||
@@ -111,7 +113,42 @@ class PrintingOrderAPITestCase(TestCase):
|
||||
self.assertEqual(order.fabric, '纯棉布料')
|
||||
# 验证 merchant 自动绑定
|
||||
self.assertEqual(order.merchant.id, self.merchant.id)
|
||||
# 验证 outgoing_date 接受日期字符串并归一为 00:00:00(按当前时区)
|
||||
self.assertIsNotNone(order.outgoing_date)
|
||||
local_dt = timezone.localtime(order.outgoing_date)
|
||||
self.assertEqual(str(local_dt.date()), '2025-11-20')
|
||||
self.assertEqual(local_dt.hour, 0)
|
||||
self.assertEqual(local_dt.minute, 0)
|
||||
|
||||
def test_filter_outgoing_date_to_includes_whole_day(self):
|
||||
"""
|
||||
outgoing_date_to 传 YYYY-MM-DD 时应包含整天:
|
||||
- outgoing_date < 次日 00:00:00
|
||||
"""
|
||||
tz = timezone.get_current_timezone()
|
||||
d0 = timezone.make_aware(datetime(2025, 11, 20, 23, 0, 0), tz)
|
||||
d1 = timezone.make_aware(datetime(2025, 11, 21, 0, 0, 0), tz)
|
||||
printing_models.PrintingOrder.objects.create(
|
||||
merchant=self.merchant,
|
||||
customer=self.customer,
|
||||
fabric='布料A',
|
||||
width='150cm',
|
||||
outgoing_date=d0,
|
||||
)
|
||||
printing_models.PrintingOrder.objects.create(
|
||||
merchant=self.merchant,
|
||||
customer=self.customer,
|
||||
fabric='布料B',
|
||||
width='150cm',
|
||||
outgoing_date=d1,
|
||||
)
|
||||
|
||||
resp = self.client.get('/api/v1/printing-orders/?limit=50&offset=0&outgoing_date_to=2025-11-20')
|
||||
self.assertEqual(resp.status_code, status.HTTP_200_OK)
|
||||
fabrics = [row['fabric'] for row in resp.data['results']]
|
||||
self.assertIn('布料A', fabrics)
|
||||
self.assertNotIn('布料B', fabrics)
|
||||
|
||||
def test_list_printing_orders(self):
|
||||
"""测试获取订单列表"""
|
||||
# 创建测试订单
|
||||
|
||||
Reference in New Issue
Block a user