293 lines
11 KiB
Python
293 lines
11 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
업로드 진행상황 다이얼로그 테스트 스크립트
|
|
|
|
이 스크립트는 새로 구현된 업로드 진행상황 다이얼로그를 테스트합니다.
|
|
실제 업로드 없이 UI와 기능을 확인할 수 있습니다.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget, QLabel
|
|
from PySide6.QtCore import QTimer, Signal
|
|
import time
|
|
|
|
# src 경로 추가
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
|
|
|
try:
|
|
from upload_progress_dialog import ModernProgressDialog
|
|
except ImportError as e:
|
|
print(f"Error importing upload_progress_dialog: {e}")
|
|
print("Make sure the src/upload_progress_dialog.py file exists")
|
|
sys.exit(1)
|
|
|
|
|
|
class TestMainWindow(QMainWindow):
|
|
"""테스트용 메인 윈도우"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("업로드 진행상황 다이얼로그 테스트")
|
|
self.setGeometry(100, 100, 400, 300)
|
|
|
|
self.progress_dialog = None
|
|
self.test_timer = None
|
|
self.test_step = 0
|
|
self.test_products = 0
|
|
|
|
self.setup_ui()
|
|
|
|
def setup_ui(self):
|
|
"""UI 설정"""
|
|
central_widget = QWidget()
|
|
self.setCentralWidget(central_widget)
|
|
|
|
layout = QVBoxLayout(central_widget)
|
|
|
|
# 제목
|
|
title_label = QLabel("업로드 진행상황 다이얼로그 테스트")
|
|
title_label.setStyleSheet("font-size: 16px; font-weight: bold; margin: 20px;")
|
|
layout.addWidget(title_label)
|
|
|
|
# 테스트 버튼들
|
|
self.test_single_button = QPushButton("단일 사업자 업로드 테스트")
|
|
self.test_single_button.clicked.connect(self.test_single_upload)
|
|
layout.addWidget(self.test_single_button)
|
|
|
|
self.test_multi_button = QPushButton("다중 사업자 업로드 테스트")
|
|
self.test_multi_button.clicked.connect(self.test_multi_upload)
|
|
layout.addWidget(self.test_multi_button)
|
|
|
|
self.test_no_market_button = QPushButton("마켓정보 없음 테스트")
|
|
self.test_no_market_button.clicked.connect(self.test_no_market_upload)
|
|
layout.addWidget(self.test_no_market_button)
|
|
|
|
# 정보 라벨
|
|
info_label = QLabel("""
|
|
테스트 설명:
|
|
• 단일 사업자: 쿠팡, 스마트스토어 마켓으로 10개 상품 업로드 시뮬레이션
|
|
• 다중 사업자: 2개 사업자로 순차 업로드 시뮬레이션 (추후 확장 기능)
|
|
• 마켓정보 없음: 선택된 마켓이 없을 때의 상황 시뮬레이션
|
|
|
|
각 테스트는 실제 업로드 없이 UI만 시뮬레이션합니다.
|
|
""")
|
|
info_label.setStyleSheet("color: #666; font-size: 11px; margin: 10px;")
|
|
layout.addWidget(info_label)
|
|
|
|
def test_single_upload(self):
|
|
"""단일 사업자 업로드 테스트"""
|
|
# 테스트 마켓 정보
|
|
test_market_info = {
|
|
'coupang': {'field1': '테스트 쿠팡 사업자'},
|
|
'ss': {'field1': '테스트 스마트스토어 사업자'}
|
|
}
|
|
|
|
# 진행상황 다이얼로그 생성
|
|
self.progress_dialog = ModernProgressDialog(self)
|
|
self.progress_dialog.start_upload(10, test_market_info)
|
|
|
|
# 시그널 연결
|
|
self.progress_dialog.cancel_requested.connect(self.on_cancel_test)
|
|
self.progress_dialog.pause_requested.connect(self.on_pause_test)
|
|
self.progress_dialog.resume_requested.connect(self.on_resume_test)
|
|
|
|
# 다이얼로그 표시
|
|
self.progress_dialog.show()
|
|
|
|
# 테스트 시뮬레이션 시작
|
|
self.start_test_simulation()
|
|
|
|
def test_multi_upload(self):
|
|
"""다중 사업자 업로드 테스트"""
|
|
# 테스트 사업자 큐
|
|
business_queue = [
|
|
{'name': '테스트 사업자 A', 'market_info': {'coupang': {'field1': '사업자A'}}},
|
|
{'name': '테스트 사업자 B', 'market_info': {'ss': {'field1': '사업자B'}}}
|
|
]
|
|
|
|
total_products_per_business = {'테스트 사업자 A': 6, '테스트 사업자 B': 4}
|
|
|
|
# 진행상황 다이얼로그 생성
|
|
self.progress_dialog = ModernProgressDialog(self)
|
|
self.progress_dialog.start_multi_business_upload(business_queue, total_products_per_business)
|
|
|
|
# 시그널 연결
|
|
self.progress_dialog.cancel_requested.connect(self.on_cancel_test)
|
|
|
|
# 다이얼로그 표시
|
|
self.progress_dialog.show()
|
|
|
|
# 다중 사업자 테스트 시뮬레이션 시작
|
|
self.start_multi_test_simulation()
|
|
|
|
def test_no_market_upload(self):
|
|
"""마켓정보 없음 테스트"""
|
|
# 빈 마켓 정보
|
|
test_market_info = {}
|
|
|
|
# 진행상황 다이얼로그 생성
|
|
self.progress_dialog = ModernProgressDialog(self)
|
|
self.progress_dialog.start_upload(5, test_market_info)
|
|
|
|
# 시그널 연결
|
|
self.progress_dialog.cancel_requested.connect(self.on_cancel_test)
|
|
|
|
# 다이얼로그 표시
|
|
self.progress_dialog.show()
|
|
|
|
# 기본 시뮬레이션 시작
|
|
self.start_simple_test_simulation()
|
|
|
|
def start_test_simulation(self):
|
|
"""단일 사업자 테스트 시뮬레이션"""
|
|
self.test_step = 0
|
|
self.test_products = 0
|
|
|
|
# 타이머 설정 (1초마다 업데이트)
|
|
self.test_timer = QTimer()
|
|
self.test_timer.timeout.connect(self.update_test_progress)
|
|
self.test_timer.start(1000)
|
|
|
|
# 초기 단계
|
|
self.progress_dialog.add_log("테스트 시뮬레이션을 시작합니다...")
|
|
self.progress_dialog.update_progress(0, "마켓정보 변경 중", 0)
|
|
|
|
def start_multi_test_simulation(self):
|
|
"""다중 사업자 테스트 시뮬레이션"""
|
|
self.test_step = 0
|
|
self.test_products = 0
|
|
|
|
# 타이머 설정 (1.5초마다 업데이트)
|
|
self.test_timer = QTimer()
|
|
self.test_timer.timeout.connect(self.update_multi_test_progress)
|
|
self.test_timer.start(1500)
|
|
|
|
# 초기 단계
|
|
self.progress_dialog.add_log("다중 사업자 테스트 시뮬레이션을 시작합니다...")
|
|
|
|
def start_simple_test_simulation(self):
|
|
"""간단한 테스트 시뮬레이션"""
|
|
self.test_step = 0
|
|
self.test_products = 0
|
|
|
|
# 타이머 설정 (800ms마다 업데이트)
|
|
self.test_timer = QTimer()
|
|
self.test_timer.timeout.connect(self.update_simple_test_progress)
|
|
self.test_timer.start(800)
|
|
|
|
# 초기 단계
|
|
self.progress_dialog.add_log("마켓정보 없음 상태로 업로드를 시작합니다...")
|
|
self.progress_dialog.update_progress(0, "상품 업로드 중", 0)
|
|
|
|
def update_test_progress(self):
|
|
"""테스트 진행상황 업데이트"""
|
|
self.test_step += 1
|
|
|
|
if self.test_step <= 3:
|
|
# 마켓정보 변경 단계
|
|
progress = (self.test_step / 3) * 100
|
|
self.progress_dialog.update_progress(0, "마켓정보 변경 중", int(progress))
|
|
self.progress_dialog.add_log(f"마켓정보 변경 진행... {int(progress)}%")
|
|
|
|
elif self.test_step <= 13:
|
|
# 상품 업로드 단계
|
|
self.test_products = self.test_step - 3
|
|
step_progress = ((self.test_step - 3) % 10) * 10
|
|
self.progress_dialog.update_progress(self.test_products, f"상품 {self.test_products} 업로드 중", step_progress)
|
|
self.progress_dialog.add_log(f"상품 {self.test_products} 업로드 중...")
|
|
|
|
else:
|
|
# 완료
|
|
self.test_timer.stop()
|
|
self.progress_dialog.complete_upload()
|
|
self.progress_dialog.add_log("테스트 시뮬레이션이 완료되었습니다!")
|
|
|
|
def update_multi_test_progress(self):
|
|
"""다중 사업자 테스트 진행상황 업데이트"""
|
|
self.test_step += 1
|
|
|
|
if self.test_step <= 2:
|
|
# 첫 번째 사업자 처리
|
|
self.progress_dialog.update_business_step("업로드정보삭제", 20)
|
|
self.progress_dialog.add_log("첫 번째 사업자: 업로드정보삭제 중...")
|
|
|
|
elif self.test_step <= 4:
|
|
self.progress_dialog.update_business_step("마켓정보변경", 40)
|
|
self.progress_dialog.add_log("첫 번째 사업자: 마켓정보변경 중...")
|
|
|
|
elif self.test_step <= 8:
|
|
product_num = self.test_step - 4
|
|
self.test_products = product_num
|
|
self.progress_dialog.update_business_step(f"상품 {product_num} 업로드", 60 + product_num * 10)
|
|
self.progress_dialog.add_log(f"첫 번째 사업자: 상품 {product_num} 업로드 중...")
|
|
|
|
elif self.test_step == 9:
|
|
# 두 번째 사업자로 전환
|
|
self.progress_dialog.proceed_to_next_business()
|
|
self.progress_dialog.add_log("두 번째 사업자 처리 시작...")
|
|
|
|
elif self.test_step <= 13:
|
|
product_num = self.test_step - 9 + 6 # 첫 번째 사업자 6개 + 추가
|
|
self.test_products = product_num
|
|
self.progress_dialog.update_business_step(f"상품 {product_num} 업로드", (self.test_step - 9) * 25)
|
|
self.progress_dialog.add_log(f"두 번째 사업자: 상품 {product_num} 업로드 중...")
|
|
|
|
else:
|
|
# 완료
|
|
self.test_timer.stop()
|
|
self.progress_dialog.proceed_to_next_business() # 모든 사업자 완료 처리
|
|
|
|
def update_simple_test_progress(self):
|
|
"""간단한 테스트 진행상황 업데이트"""
|
|
self.test_step += 1
|
|
self.test_products = self.test_step
|
|
|
|
if self.test_products <= 5:
|
|
progress = self.test_products * 20
|
|
self.progress_dialog.update_progress(self.test_products, f"상품 {self.test_products} 업로드 중", progress)
|
|
self.progress_dialog.add_log(f"상품 {self.test_products} 업로드 완료")
|
|
else:
|
|
# 완료
|
|
self.test_timer.stop()
|
|
self.progress_dialog.complete_upload()
|
|
self.progress_dialog.add_log("마켓정보 없음 상태 테스트 완료!")
|
|
|
|
def on_cancel_test(self):
|
|
"""테스트 취소"""
|
|
if self.test_timer:
|
|
self.test_timer.stop()
|
|
print("테스트가 취소되었습니다.")
|
|
|
|
def on_pause_test(self):
|
|
"""테스트 일시정지"""
|
|
if self.test_timer:
|
|
self.test_timer.stop()
|
|
print("테스트가 일시정지되었습니다.")
|
|
|
|
def on_resume_test(self):
|
|
"""테스트 재개"""
|
|
if self.test_timer:
|
|
self.test_timer.start()
|
|
print("테스트가 재개되었습니다.")
|
|
|
|
|
|
def main():
|
|
"""메인 함수"""
|
|
app = QApplication(sys.argv)
|
|
|
|
# 애플리케이션 정보 설정
|
|
app.setApplicationName("업로드 진행상황 다이얼로그 테스트")
|
|
app.setApplicationVersion("1.0")
|
|
|
|
# 메인 윈도우 생성 및 표시
|
|
main_window = TestMainWindow()
|
|
main_window.show()
|
|
|
|
# 이벤트 루프 시작
|
|
sys.exit(app.exec())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|