Add EDDM size, income, businesses and USPS map link (#18)
## Summary Closes #17. - 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. Template: westfarn/web_django_template#13 ## 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: #18
This commit was merged in pull request #18.
This commit is contained in:
1 parent
045e956011
commit
8e3c0a5909
6 files changed
+254
-2
No files matched your search
@@ -1,6 +1,7 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import Client, TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from unittest.mock import patch
|
||||
import json
|
||||
|
||||
from contacts.models import Channel, ConsentRecord, Contact, Suppression
|
||||
@@ -1559,6 +1560,8 @@ class CampaignUtmLinkTests(TestCase):
|
||||
self.assertContains(response, "data-utm-qr")
|
||||
self.assertContains(response, "utm_campaign")
|
||||
self.assertContains(response, reverse("messaging:campaign_short_link"))
|
||||
self.assertContains(response, "https://eddm.usps.com/eddm/select-routes.htm")
|
||||
self.assertContains(response, "Open USPS EDDM map")
|
||||
|
||||
def test_detail_shows_tracked_url(self):
|
||||
with self.settings(PUBLIC_SITE_URL="https://mkdrealtor.com"):
|
||||
@@ -1721,6 +1724,12 @@ class CarrierRoutePostcardTests(TestCase):
|
||||
email="mail@example.com",
|
||||
postal_address=Contact.make_postal_address(line1="9 Main"),
|
||||
)
|
||||
self.eddm_patcher = patch(
|
||||
"messaging.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 messaging.providers.postcard import pcm as pcm_mod
|
||||
@@ -1776,6 +1785,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(
|
||||
"messaging.providers.postcard.pcm.design_pricing", return_value=[]
|
||||
):
|
||||
with patch(
|
||||
"messaging.providers.postcard.pcm.list_count_zipcode",
|
||||
return_value=payload,
|
||||
):
|
||||
response = self.client.post(
|
||||
reverse("messaging: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):
|
||||
from unittest.mock import patch
|
||||
|
||||
Reference in new issue
Block a user