Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DST-932 - Report a breach - Integrity error on last step of the form #295

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_app/utils/address_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def turn_companies_house_into_normal_address_dict(address_dict: Dict[str, Any])
try:
new_address_dict["town_or_city"] = address_dict["locality"]
except KeyError:
pass
new_address_dict["town_or_city"] = ""

return new_address_dict

Expand Down
Empty file.
55 changes: 55 additions & 0 deletions tests/test_unit/test_utils/test_address_formatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from utils.address_formatter import turn_companies_house_into_normal_address_dict


def test_turn_companies_house_into_normal_address_dict():
companies_house_address_dict = {
"address_line_1": "Buckingham Palace",
"address_line_2": "Address Line 2",
"country": "United Kingdom",
"locality": "London",
"postal_code": "ER3 SOS",
}
normal_dict = turn_companies_house_into_normal_address_dict(companies_house_address_dict)
assert normal_dict == {
"address_line_1": "Buckingham Palace",
"address_line_2": "Address Line 2",
"country": "GB",
"locality": "London",
"postal_code": "ER3 SOS",
"town_or_city": "London",
}

# now checking no country
companies_house_address_dict = {
"address_line_1": "Buckingham Palace",
"address_line_2": "Address Line 2",
"locality": "London",
"postal_code": "ER3 SOS",
}
normal_dict = turn_companies_house_into_normal_address_dict(companies_house_address_dict)
# it should default to GB
assert normal_dict == {
"address_line_1": "Buckingham Palace",
"address_line_2": "Address Line 2",
"country": "GB",
"locality": "London",
"postal_code": "ER3 SOS",
"town_or_city": "London",
}

# now checking no locality
companies_house_address_dict = {
"address_line_1": "Buckingham Palace",
"address_line_2": "Address Line 2",
"country": "United Kingdom",
"postal_code": "ER3 SOS",
}
normal_dict = turn_companies_house_into_normal_address_dict(companies_house_address_dict)
# it should default to an empty string
assert normal_dict == {
"address_line_1": "Buckingham Palace",
"address_line_2": "Address Line 2",
"country": "GB",
"postal_code": "ER3 SOS",
"town_or_city": "",
}
Loading