# -*- coding: utf-8 -*- """선별 주문 테스트 - 모듈 리로드 포함""" import sys; sys.path.insert(0, '.'); import wholesale_path # 모듈 리로드! import importlib import wholesale.sooin importlib.reload(wholesale.sooin) from wholesale import SooinSession # 싱글톤 리셋 SooinSession._instance = None 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.get('message')}") # 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(f'\n🤔 예상 외 결과: {cart3["total_items"]}개 남음')