Files
openclaw/agents/stock/workspace/scripts/tests/test_ipo_alert.py
T
hyowons 5e47a15547 자산웹 공모주 탭 추가 + 상장일 관심종목 자동등록
- 자산정보 > 공모주 sub-tab: 오늘청약(증권사별 아이템, 기본 접힘) / 청약완료(상장일까지)
- 관리자(청약)·가희(청약) 버튼 — 사람별 종목당 1건 기록 (state/behive_ipo_subscribed.json)
- 타이틀 [청약] 배지: 미완료 청약 또는 청약 종목 상장일
- ipo_alert listing(08:30)에서 청약완료 종목을 상장일에 관심종목 등록
- 데이터는 네이버 IPO API, 증거금·수수료는 ipo_alert._manager_blocks 재사용(키움 콜 0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 12:32:15 +09:00

69 lines
2.5 KiB
Python

import sys
import unittest
from datetime import date
from pathlib import Path
from unittest.mock import patch
SCRIPTS = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(SCRIPTS))
import ipo_alert
class IpoAlertTests(unittest.TestCase):
def setUp(self):
self.row = {
'ipoCode': 'A250030',
'compName': '진코스텍',
'poStartDate': '2026-10-02',
'poEndDate': '2026-10-06',
'lcalDate': '2026-10-15',
'fixPubPrice': '23500',
'orgNm': '하나증권',
}
self.detail = {
'ipoInfo': {
'compName': '진코스텍',
'poStartDate': '2026-10-02',
'poEndDate': '2026-10-06',
'lcalDate': '2026-10-15',
},
'registrationStatement': {'sbscMrgnRatio': '50.00'},
'demandForecastingResult': {'fixPubPrice': '23500'},
'joinManagers': [{'orgNm': '하나증권', 'sbscMinNum': '10'}],
}
def test_subscription_format_uses_first_day_and_minimum_cash(self):
text = ipo_alert.format_alert('subscription', self.row, self.detail)
self.assertIn('종목명 : 진코스텍', text)
self.assertIn('증권사 : 하나증권', text)
self.assertIn('청약일 : 2026-10-02 ~ 2026-10-06', text)
self.assertIn('증거금 : 117,500원(최소 10주)', text)
self.assertNotIn('23,500원', text)
self.assertNotIn('50%', text)
self.assertIn('수수료 2,000원(온라인 일반 기준)', text)
def test_listing_uses_listing_date(self):
text = ipo_alert.format_alert('listing', self.row, self.detail)
self.assertIn('[신규 상장]', text)
self.assertIn('상장일 : 2026-10-15', text)
def test_collect_subscription_matches_only_first_day(self):
payload = {
'examinationList': [], 'demandForecastingList': [],
'forecastingCompleteList': [],
'subscriptionList': [self.row],
'subscriptionCompleteList': [], 'listingList': [],
}
with patch.object(ipo_alert, 'fetch', return_value=ipo_alert.json.dumps(payload)), patch.object(
ipo_alert, '_detail', return_value=self.detail
):
first = ipo_alert.collect_for_date('subscription', date(2026, 10, 2))
second = ipo_alert.collect_for_date('subscription', date(2026, 10, 3))
self.assertEqual(len(first), 1)
self.assertEqual(second, [])
if __name__ == '__main__':
unittest.main()