Skip to content

Commit

Permalink
Merge branch 'main' into ras-1351-update-python-version-redo
Browse files Browse the repository at this point in the history
  • Loading branch information
anwilkie authored Dec 2, 2024
2 parents e5c7eb9 + 633ed81 commit d306bf0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
16 changes: 0 additions & 16 deletions ras_party/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,6 @@ def to_respondent_dict(self):
"password_reset_counter": self.password_reset_counter,
}

def to_dict(self) -> dict:
return {
"id": self.id,
"party_uuid": self.party_uuid,
"status": RespondentStatus(self.status).name,
"email_address": self.email_address,
"pending_email_address": self.pending_email_address,
"first_name": self.first_name,
"last_name": self.last_name,
"telephone": self.telephone,
"created_on": self.created_on,
"mark_for_deletion": self.mark_for_deletion,
"password_verification_token": self.password_verification_token,
"password_reset_counter": self.password_reset_counter,
}

def to_respondent_with_associations_dict(self):
respondent_dict = self.to_respondent_dict()
respondent_dict["associations"] = self._get_business_associations(self.businesses)
Expand Down
2 changes: 1 addition & 1 deletion ras_party/views/respondent_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_respondent_by_party_id(party_id: UUID) -> Response:

respondent = respondent_controller.get_respondent_by_party_id(party_id)
if respondent:
return make_response(respondent.to_dict(), 200)
return make_response(respondent.to_respondent_dict(), 200)

return make_response(f"respondent not found for party_id {party_id}", 404)

Expand Down
15 changes: 14 additions & 1 deletion test/test_respondent_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,22 @@ def test_get_respondents_by_party_id(self, respondents_by_party_id):

# Then a 200 is returned with the correct Respondent
json_response = json.loads(response.data)
expected_response = {
"emailAddress": "email address",
"firstName": "first name",
"id": "7ab8f3b6-f436-400d-8911-335a61ec58e5",
"lastName": "last name",
"markForDeletion": None,
"password_reset_counter": None,
"password_verification_token": None,
"pendingEmailAddress": None,
"sampleUnitType": "BI",
"status": "ACTIVE",
"telephone": "telephone",
}
respondent["status"] = "ACTIVE" # The to_dict is returning the ResponseStatus name so this needs to be updated
self.assertEqual(response.status_code, 200)
self.assertEqual(json_response, json_response | respondent)
self.assertEqual(json_response, expected_response)

def test_get_respondents_by_party_id_invalid_uuid(self):
# Given/When the end point is called with an invalid uuid for party_id
Expand Down

0 comments on commit d306bf0

Please sign in to comment.