Skip to content

Commit

Permalink
[EDSI-615] Fix 'Phone: None' appearing in full listings of student se…
Browse files Browse the repository at this point in the history
…arches (#123)

* [EDSI-615] Fix 'Phone: None' appearing in full listings of student searches

* [Bot] Update version to 2.1.1

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Thomas Thorogood and github-actions[bot] authored Nov 3, 2021
1 parent 909a465 commit 81773da
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion husky_directory/services/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def _resolve_phones(
model = PhoneContactMethods()

if student_affiliation:
model.phones.append(student_affiliation.directory_listing.phone)
if student_affiliation.directory_listing.phone:
model.phones.append(student_affiliation.directory_listing.phone)

return model

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "uw-husky-directory"
version = "2.1.0"
version = "2.1.1"
description = "An updated version of the UW Directory"
authors = ["Thomas Thorogood <[email protected]>"]
license = "MIT"
Expand Down
21 changes: 21 additions & 0 deletions tests/blueprints/test_search_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ def test_render_full_success(self, log_in):
"li", str(profile.affiliations.employee.mail_stop)
)

def test_render_student_no_phone(self):
self.flask_client.get("/saml/login", follow_redirects=True)
profile = self.mock_people.published_student
profile.affiliations.student.directory_listing.phone = None
profile.affiliations.employee = None
self.mock_send_request.return_value = self.mock_people.as_search_output(profile)

response = self.flask_client.post(
"/",
data={
"query": "lovelace",
"method": "name",
"length": "full",
"population": "all",
},
)

with self.html_validator.validate_response(response):
assert response.status_code == 200
self.html_validator.assert_not_has_tag_with_text("li", "Phone:")

def test_render_no_results(self):
self.mock_send_request.return_value = self.mock_people.as_search_output()
response = self.flask_client.post("/", data={"query": "lovelace"})
Expand Down

0 comments on commit 81773da

Please sign in to comment.