55 lines
2.8 KiB
Python
55 lines
2.8 KiB
Python
"""现货看板指标与图表接口回归测试。"""
|
|
import unittest
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
ROUTE=(ROOT/'routes/spot.py').read_text(encoding='utf-8')
|
|
APP=(ROOT/'static/js/app.js').read_text(encoding='utf-8')
|
|
class SpotDashboardTest(unittest.TestCase):
|
|
def test_dashboard_api_and_metrics_exist(self):
|
|
self.assertIn("@spot_bp.route('/api/spot/dashboard')",ROUTE)
|
|
for key in ('total_forms','total_sample_quantity','unauthorized_count','listed_count'):
|
|
self.assertIn("'"+key+"'",ROUTE)
|
|
self.assertNotIn("'form_only_unsampled':", ROUTE)
|
|
self.assertNotIn("'sales_total':", ROUTE)
|
|
self.assertIn("sample_status,'')) IN ('已到货','样品已到货')", ROUTE)
|
|
self.assertIn("sample_status,'')) = '样品已到货'", ROUTE)
|
|
self.assertIn("a.department", ROUTE)
|
|
self.assertIn("sample_department", ROUTE)
|
|
self.assertIn("p.planning_new_old,'')) IN ('新品','是')", ROUTE)
|
|
self.assertIn("'selected_summary_month'", ROUTE)
|
|
def test_charts_exist(self):
|
|
for key in ('operator_sampling','first_no_sales','top10_sales'):
|
|
self.assertIn("'"+key+"'",ROUTE)
|
|
for text in ('平台各小组申请采样情况','首批无销量','现货销量前十'):
|
|
self.assertIn(text,APP)
|
|
self.assertNotIn('type=\"month\"',APP)
|
|
self.assertIn('sales_start_month=',APP)
|
|
self.assertIn('sales_end_month=',APP)
|
|
self.assertIn('age >= days',ROUTE)
|
|
self.assertIn("'monthly_sales'",ROUTE)
|
|
for field in ('goods_code','product_name','platform','category','sales','first_inventory_date'):
|
|
self.assertIn("'"+field+"'",ROUTE)
|
|
self.assertIn('first_no_sales_size = 20',ROUTE)
|
|
self.assertIn('renderSpotFirstNoSalesList',APP)
|
|
for text in ('商家编码','货品名称','平台','类目','销量','首批入库时间','每页20条'):
|
|
self.assertIn(text,APP)
|
|
self.assertIn('openSpotMonthPicker',APP)
|
|
self.assertIn('spot-month-modal',APP)
|
|
self.assertIn('spot-month-grid',APP)
|
|
self.assertIn('renderSpotDepartmentFilter',APP)
|
|
self.assertIn('洁维塔',APP)
|
|
self.assertIn('泊紫汀兰',APP)
|
|
self.assertIn('text-align:left!important',APP)
|
|
self.assertNotIn("title==='现货销量前十'?'wide':''",APP)
|
|
def test_spot_dashboard_replaces_placeholder(self):
|
|
self.assertIn('loadSpotDashboardPage',APP)
|
|
self.assertIn("if (title === '现货数据看板')",APP)
|
|
def test_first_no_sales_has_dark_header_and_visible_column_dividers(self):
|
|
self.assertIn('.spot-list-table thead th{background:#4b5563;color:#fff;',APP)
|
|
self.assertIn('.spot-list-table th,.spot-list-table td{padding:10px 12px;border:1px solid #64748b;',APP)
|
|
self.assertNotIn('.spot-list-table thead th+th{',APP)
|
|
self.assertNotIn('.spot-list-table tbody td+td{',APP)
|
|
self.assertNotIn('white-space:nowrap;border-bottom:2px solid #374151',APP)
|
|
self.assertIn('text-align:left!important',APP)
|
|
if __name__=='__main__':unittest.main()
|