39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import asyncio
|
|
import logging
|
|
from VertexAITranslator import VertexAITranslator # VertexAITranslator 파일이 같은 폴더에 있다고 가정
|
|
|
|
# 로거 설정
|
|
logger = logging.getLogger("VertexAITranslatorTest")
|
|
logger.setLevel(logging.DEBUG)
|
|
console_handler = logging.StreamHandler()
|
|
console_handler.setLevel(logging.DEBUG)
|
|
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
|
console_handler.setFormatter(formatter)
|
|
logger.addHandler(console_handler)
|
|
|
|
# 테스트용 옵션 데이터와 상품명 설정
|
|
original_data = {
|
|
"option1": "전기 히터 2000W",
|
|
"option2": "멀티 난방 패드",
|
|
}
|
|
product_name = "전기 난방기"
|
|
|
|
async def test_translate_options():
|
|
# VertexAITranslator 객체 초기화
|
|
translator = VertexAITranslator(logger)
|
|
|
|
# translate_options 메서드 테스트
|
|
try:
|
|
logger.debug("translate_options 메서드 테스트 시작...")
|
|
translated_data = await translator.translate_options(original_data, product_name)
|
|
logger.debug(f"번역 결과: {translated_data}")
|
|
except Exception as e:
|
|
logger.error(f"테스트 중 오류 발생: {e}")
|
|
|
|
# asyncio.run을 사용하여 비동기 메서드 실행
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_translate_options())
|
|
|
|
|
|
|