Template
Add EDDM size, income, businesses and USPS map link (#14)
## Summary Closes #13. - Mirror Monica: join USPS EDDM GIS stats onto the carrier-route picker (household size, median income, business count). - Add Open USPS EDDM map link next to Find routes. - GIS miss stays a dash and does not block Find routes. PCM households and cost unchanged. Monica: ai_ml_operations/monica_site#17 ## Test plan - [ ] Find routes for a ZIP; table shows Size / Income / Businesses columns - [ ] Missing GIS values render as — - [ ] Open USPS EDDM map opens eddm.usps.com - [ ] Quote and 1–2 route send still work - [ ] `CarrierRoutePostcardTests` pass Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
1 parent
f2eb4b7152
commit
7ff52c776b
6 files changed
+254
-3
No files matched your search
@@ -304,13 +304,15 @@ class PostcardUtmPanelTests(TestCase):
|
||||
self.assertContains(response, "qrcode.min.js")
|
||||
self.assertContains(response, "data-utm-qr")
|
||||
self.assertContains(response, reverse("campaign_short_link"))
|
||||
self.assertContains(response, "https://eddm.usps.com/eddm/select-routes.htm")
|
||||
self.assertContains(response, "Open USPS EDDM map")
|
||||
|
||||
|
||||
class CarrierRoutePostcardTests(TestCase):
|
||||
def setUp(self):
|
||||
User = get_user_model()
|
||||
self.user = User.objects.create_user(
|
||||
username="routes", password="test-pass-123"
|
||||
username="routes", password="test-pass-123", is_staff=True
|
||||
)
|
||||
self.client = Client()
|
||||
self.client.login(username="routes", password="test-pass-123")
|
||||
@@ -318,6 +320,12 @@ class CarrierRoutePostcardTests(TestCase):
|
||||
email="mail@example.com",
|
||||
postal_address=Contact.make_postal_address(line1="9 Main"),
|
||||
)
|
||||
self.eddm_patcher = patch(
|
||||
"directmail.providers.postcard.usps_eddm.fetch_eddm_route_stats",
|
||||
return_value={},
|
||||
)
|
||||
self.eddm_stats = self.eddm_patcher.start()
|
||||
self.addCleanup(self.eddm_patcher.stop)
|
||||
|
||||
def test_pick_unit_price_uses_break_qty_and_fallback(self):
|
||||
from directmail.providers.postcard import pcm as pcm_mod
|
||||
@@ -371,6 +379,49 @@ class CarrierRoutePostcardTests(TestCase):
|
||||
self.assertEqual(len(data["routes"]), 2)
|
||||
self.assertEqual(data["routes"][0]["cost"], 60.0)
|
||||
self.assertEqual(data["mail_class"], "Standard")
|
||||
self.assertEqual(
|
||||
data["eddm_map_url"], "https://eddm.usps.com/eddm/select-routes.htm"
|
||||
)
|
||||
|
||||
def test_quote_search_includes_eddm_demographics(self):
|
||||
self.eddm_stats.return_value = {
|
||||
"60540:C001": {
|
||||
"businesses": 22,
|
||||
"household_size": 2.6,
|
||||
"median_income": 120000,
|
||||
"residential": 108,
|
||||
}
|
||||
}
|
||||
payload = {
|
||||
"listCountID": 11,
|
||||
"recordCount": 120,
|
||||
"breakdown": [
|
||||
{
|
||||
"breakdownType": "ZipCRRT",
|
||||
"data": [
|
||||
{"code": "60540:C001", "text": "NAPERVILLE", "total": 120},
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
with self.settings(PCM_POSTCARD_PRICE_STANDARD="0.50"):
|
||||
with patch(
|
||||
"directmail.providers.postcard.pcm.design_pricing", return_value=[]
|
||||
):
|
||||
with patch(
|
||||
"directmail.providers.postcard.pcm.list_count_zipcode",
|
||||
return_value=payload,
|
||||
):
|
||||
response = self.client.post(
|
||||
reverse("directmail:postcard_quote"),
|
||||
data='{"action":"search","zip":"60540","size":"68"}',
|
||||
content_type="application/json",
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
row = response.json()["routes"][0]
|
||||
self.assertEqual(row["businesses"], 22)
|
||||
self.assertEqual(row["household_size"], 2.6)
|
||||
self.assertEqual(row["median_income"], 120000)
|
||||
|
||||
def test_quote_select_and_save_draft(self):
|
||||
import json
|
||||
|
||||
Reference in new issue
Block a user