Skip to content

Commit ba816a6

Browse files
committed
pull apart to get zip
1 parent 03a949a commit ba816a6

File tree

3 files changed

+53
-19
lines changed

3 files changed

+53
-19
lines changed

src/meshapi/tests/sample_join_form_data.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,41 @@
134134
},
135135
}
136136

137+
valid_join_form_submission_zip_is_updated = {
138+
"first_name": "John",
139+
"last_name": "Smith",
140+
"email_address": "[email protected]",
141+
"phone_number": "+1 585-758-3425", # CSH's phone number :P
142+
"parsed_phone": "+1 585-758-3425", # CSH's phone number :P
143+
"street_address": "151 Broome Street", # Also covers New York County Test Case
144+
"parsed_street_address": "151 Broome Street",
145+
"city": "Manhattan",
146+
"parsed_city": "New York",
147+
"state": "NY",
148+
"zip_code": "10002",
149+
"parsed_zip_code": "10003",
150+
"apartment": "",
151+
"roof_access": True,
152+
"referral": "Googled it or something IDK",
153+
"ncl": True,
154+
"trust_me_bro": True,
155+
"dob_addr_response": {
156+
"features": [
157+
{
158+
"properties": {
159+
"housenumber": "151",
160+
"street": "Broome Street",
161+
"borough": "New York",
162+
"region_a": "NY",
163+
"postalcode": "10003",
164+
"addendum": {"pad": {"bin": 1077609}},
165+
},
166+
"geometry": {"coordinates": [0, 0]},
167+
}
168+
]
169+
},
170+
}
171+
137172
valid_join_form_submission_with_apartment_in_address = {
138173
"first_name": "John",
139174
"last_name": "Smith",

src/meshapi/tests/test_join_form.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
valid_join_form_submission_city_needs_expansion,
3333
valid_join_form_submission_phone_needs_expansion,
3434
valid_join_form_submission_street_needs_expansion,
35+
valid_join_form_submission_zip_is_updated,
3536
valid_join_form_submission_with_apartment_in_address,
3637
)
3738
from .util import TestThread
@@ -94,6 +95,9 @@ def pull_apart_join_form_submission(submission):
9495
del request["parsed_street_address"]
9596
del request["dob_addr_response"]
9697
del request["parsed_phone"]
98+
99+
if "parsed_zip_code" in request:
100+
del request["parsed_zip_code"]
97101
if "parsed_city" in request:
98102
del request["parsed_city"]
99103

@@ -105,6 +109,7 @@ def pull_apart_join_form_submission(submission):
105109
s.street_address = submission["parsed_street_address"]
106110
s.city = submission["parsed_city"] if "parsed_city" in submission else submission["city"]
107111
s.state = submission["state"]
112+
s.zip_code = submission["parsed_zip_code"] if "parsed_zip_code" in submission else submission["zip_code"]
108113
s.phone_number = submission["parsed_phone"]
109114

110115
return request, s
@@ -222,14 +227,15 @@ def test_valid_join_form_captcha_valid(self, mock_get_client_ip, validate_captch
222227

223228
@parameterized.expand(
224229
[
225-
[valid_join_form_submission_phone_needs_expansion],
226-
[valid_join_form_submission_city_needs_expansion],
227-
[valid_join_form_submission_street_needs_expansion],
228-
[richmond_join_form_submission],
229-
[kings_join_form_submission],
230-
[queens_join_form_submission],
231-
[bronx_join_form_submission],
232-
[valid_join_form_submission_with_apartment_in_address],
230+
#[valid_join_form_submission_phone_needs_expansion],
231+
#[valid_join_form_submission_city_needs_expansion],
232+
#[valid_join_form_submission_street_needs_expansion],
233+
[valid_join_form_submission_zip_is_updated],
234+
#[richmond_join_form_submission],
235+
#[kings_join_form_submission],
236+
#[queens_join_form_submission],
237+
#[bronx_join_form_submission],
238+
#[valid_join_form_submission_with_apartment_in_address],
233239
]
234240
)
235241
def test_valid_join_form_with_member_confirmation(self, submission):
@@ -261,9 +267,9 @@ def test_valid_join_form_with_member_confirmation(self, submission):
261267
self.assertEqual(
262268
code,
263269
response.status_code,
264-
f"status code incorrect for Valid Join Form. Should be {code}, but got {response.status_code}.\n Response is: {response.content.decode('utf-8')}",
270+
f"status code incorrect for test_valid_join_form_with_member_confirmation. Should be {code}, but got {response.status_code}.\n Response is: {response.content.decode('utf-8')}",
265271
)
266-
validate_successful_join_form_submission(self, "Valid Join Form", s, response)
272+
validate_successful_join_form_submission(self, "test_valid_join_form_with_member_confirmation", s, response)
267273

268274
def test_phone_number_is_silently_corrected(self):
269275
self.requests_mocker.get(

src/meshapi/zips.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Optional
22

3-
43
bronx = [
54
"10466",
65
"10468",
@@ -238,13 +237,8 @@
238237
QUEENS = "queens"
239238
RICHMOND = "richmond"
240239

241-
zips = {
242-
BRONX: bronx,
243-
NEW_YORK: new_york,
244-
KINGS: kings,
245-
QUEENS: queens,
246-
RICHMOND: richmond
247-
}
240+
zips = {BRONX: bronx, NEW_YORK: new_york, KINGS: kings, QUEENS: queens, RICHMOND: richmond}
241+
248242

249243
class NYCZipCodes:
250244
@staticmethod
@@ -257,4 +251,3 @@ def get_borough(zip_code: str) -> Optional[str]:
257251
if zip_code in z:
258252
return borough
259253
return None
260-

0 commit comments

Comments
 (0)