| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import sys
- import unittest
- from pathlib import Path
- from unittest.mock import patch
- ROOT = Path(__file__).resolve().parent
- if str(ROOT) not in sys.path:
- sys.path.insert(0, str(ROOT))
- PROJECT_ROOT = ROOT.parents[1]
- if str(PROJECT_ROOT) not in sys.path:
- sys.path.insert(0, str(PROJECT_ROOT))
- from tools.ad_creation import AdCandidate, build_ad_request_body
- def _candidate() -> AdCandidate:
- return AdCandidate(
- account_id=123,
- adgroup_name="test-ad",
- site_set=["SITE_SET_WECHAT"],
- custom_audience=None,
- bid_amount_fen=35,
- audience_tier_label="泛人群",
- age=[{"min": 45, "max": 66}],
- location_types=["LIVE_IN"],
- region_ids=[1],
- daily_budget_fen=10000,
- time_series="1" * 48,
- delivery_version="miniapp_user_growth_v1",
- fingerprint="fp",
- wechat_position=None,
- )
- class AdCreationStatusTest(unittest.TestCase):
- def test_ad_request_defaults_to_normal_status(self):
- with patch("tools.ad_creation.get_account_feedback_id", return_value=6700001):
- body = build_ad_request_body(_candidate(), begin_date="2026-07-01")
- self.assertEqual(body["configured_status"], "AD_STATUS_NORMAL")
- if __name__ == "__main__":
- unittest.main()
|