- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
70 lines
2.0 KiB
Python
70 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
지오영 clear_cart (개선된 버전) 테스트
|
|
"""
|
|
import sys
|
|
sys.path.insert(0, r'c:\Users\청춘약국\source\pharmacy-wholesale-api')
|
|
|
|
# 싱글톤 초기화 강제
|
|
import importlib
|
|
import wholesale.geoyoung
|
|
importlib.reload(wholesale.geoyoung)
|
|
|
|
from dotenv import load_dotenv
|
|
load_dotenv(r'c:\Users\청춘약국\source\pharmacy-wholesale-api\.env')
|
|
|
|
from wholesale.geoyoung import GeoYoungSession
|
|
|
|
def test_clear_cart_new():
|
|
# 싱글톤 리셋
|
|
GeoYoungSession._instance = None
|
|
session = GeoYoungSession()
|
|
|
|
print("=" * 60)
|
|
print("지오영 clear_cart (개선된 버전) 테스트")
|
|
print("=" * 60)
|
|
|
|
# 1. 로그인
|
|
if not session.login():
|
|
print("❌ 로그인 실패")
|
|
return
|
|
print("✅ 로그인 성공\n")
|
|
|
|
# 2. 제품 추가 (테스트용)
|
|
print("📦 테스트용 제품 추가 중...")
|
|
add_result = session.add_to_cart('033133', 1) # 코자르탄
|
|
print(f" 결과: {add_result}")
|
|
|
|
import time
|
|
time.sleep(1)
|
|
|
|
# 3. 장바구니 확인
|
|
print("\n📦 [BEFORE] 장바구니:")
|
|
cart = session.get_cart()
|
|
print(f" 품목 수: {cart.get('total_items')}")
|
|
for item in cart.get('items', []):
|
|
print(f" • {item.get('product_name')} (code: {item.get('product_code')})")
|
|
|
|
if not cart.get('items'):
|
|
print(" ⚠️ 장바구니 비어있음. 제품 추가 실패")
|
|
return
|
|
|
|
# 4. clear_cart 호출
|
|
print("\n🗑️ clear_cart() 호출 (개선된 버전)...")
|
|
clear_result = session.clear_cart()
|
|
print(f" 결과: {clear_result}")
|
|
|
|
# 5. 다시 확인
|
|
time.sleep(1)
|
|
print("\n📦 [AFTER] 장바구니:")
|
|
cart_after = session.get_cart()
|
|
print(f" 품목 수: {cart_after.get('total_items')}")
|
|
|
|
if not cart_after.get('items'):
|
|
print("\n✅ clear_cart 성공!")
|
|
else:
|
|
print(f"\n❌ clear_cart 실패! 아직 {len(cart_after.get('items', []))}개 남아있음")
|
|
|
|
if __name__ == "__main__":
|
|
test_clear_cart_new()
|