From 81773da8f66a3b8f199b6b4c78e6ce22dd51b77c Mon Sep 17 00:00:00 2001 From: Thomas Thorogood Date: Wed, 3 Nov 2021 13:58:35 -0700 Subject: [PATCH] [EDSI-615] Fix 'Phone: None' appearing in full listings of student searches (#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> --- husky_directory/services/translator.py | 3 ++- pyproject.toml | 2 +- tests/blueprints/test_search_blueprint.py | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/husky_directory/services/translator.py b/husky_directory/services/translator.py index 69d963ec..e5ab71dd 100644 --- a/husky_directory/services/translator.py +++ b/husky_directory/services/translator.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 28d4c6be..32d111f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT" diff --git a/tests/blueprints/test_search_blueprint.py b/tests/blueprints/test_search_blueprint.py index 3ead3987..99eea757 100644 --- a/tests/blueprints/test_search_blueprint.py +++ b/tests/blueprints/test_search_blueprint.py @@ -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"})