- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""선별 주문 테스트 - 체크박스로 특정 품목만 주문"""
|
|
import sys; sys.path.insert(0, '.'); import wholesale_path
|
|
from wholesale import SooinSession
|
|
|
|
s = SooinSession()
|
|
s.login()
|
|
s.clear_cart()
|
|
|
|
# 1. 품목 2개 담기
|
|
print('=== 1. 품목 2개 담기 ===')
|
|
r1 = s.search_products('코자정')
|
|
p1 = r1['items'][0]
|
|
s.add_to_cart(p1['internal_code'], qty=1, price=p1['price'], stock=p1['stock'])
|
|
print(f"담음: {p1['name']}")
|
|
|
|
r2 = s.search_products('디카맥스')
|
|
p2 = r2['items'][0]
|
|
s.add_to_cart(p2['internal_code'], qty=1, price=p2['price'], stock=p2['stock'])
|
|
print(f"담음: {p2['name']}")
|
|
|
|
# 2. 장바구니 확인
|
|
print('\n=== 2. 장바구니 확인 ===')
|
|
cart = s.get_cart()
|
|
print(f"품목 수: {cart['total_items']}")
|
|
for item in cart['items']:
|
|
status = '활성' if item.get('active') else '취소'
|
|
print(f" [{status}] {item['product_name'][:25]} (row:{item['row_index']})")
|
|
|
|
# 3. 코자정(row 0)만 취소 → 디카맥스만 주문되어야 함
|
|
print('\n=== 3. 코자정 취소 (row 0) ===')
|
|
cancel_result = s.cancel_item(row_index=0)
|
|
print(f"취소 결과: {cancel_result}")
|
|
|
|
# 4. 장바구니 다시 확인
|
|
print('\n=== 4. 장바구니 재확인 ===')
|
|
cart2 = s.get_cart()
|
|
for item in cart2['items']:
|
|
status = '✅활성' if item.get('active') else '❌취소'
|
|
print(f" {status} {item['product_name'][:25]}")
|
|
|
|
# 5. 주문 (취소 안 된 것만 나감)
|
|
print('\n=== 5. 주문 전송 ===')
|
|
order_result = s.submit_order()
|
|
print(f"주문 결과: {order_result}")
|
|
|
|
# 6. 장바구니 확인 - 디카맥스만 주문됐으면, 코자정은 남아있어야 함
|
|
print('\n=== 6. 주문 후 장바구니 ===')
|
|
cart3 = s.get_cart()
|
|
print(f"품목 수: {cart3['total_items']}")
|
|
for item in cart3['items']:
|
|
print(f" - {item['product_name'][:25]}")
|
|
|
|
if cart3['total_items'] == 1:
|
|
print('\n🎉 성공! 취소된 품목(코자정)은 남고, 디카맥스만 주문됨!')
|
|
elif cart3['total_items'] == 0:
|
|
print('\n⚠️ 둘 다 주문됨 - 체크박스 로직 안 먹힘')
|
|
else:
|
|
print('\n🤔 예상 외 결과')
|