Skip to content

Commit

Permalink
Add additional testing for sublet drafting
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-Jess committed Mar 24, 2024
1 parent 2e3439d commit 8e0d48d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/sublet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def field_bad(field, validated_data, instance):

if bad_fields := [field for field in fields if field_bad(field, validated_data, instance)]:
raise serializers.ValidationError(
f"{', '.join(bad_fields)} are required to publish sublet."
f"fields: {', '.join(bad_fields)} are required to publish sublet."
)

class Meta:
Expand Down
10 changes: 8 additions & 2 deletions backend/tests/sublet/test_sublets.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_update_sublet(self):
response = self.client.post("/sublet/properties/", payload)
old_id = json.loads(response.content)["id"]
# Update the sublet using the serializer
data = {"title": "New Title", "beds": 3, "amenities": ["Amenity1"]}
data = {"title": "New Title", "beds": 3, "amenities": ["Amenity1"], "address": ""}
response = self.client.patch(f"/sublet/properties/{str(old_id)}/", data)
res_json = json.loads(response.content)
self.assertEqual(3, res_json["beds"])
Expand All @@ -103,7 +103,13 @@ def test_update_sublet(self):
self.assertEqual(1, len(res_json["amenities"]))
payload["address"] = ""
payload["is_published"] = True
self.client.patch(f"/sublet/properties/{str(old_id)}/", payload)
response = self.client.patch(f"/sublet/properties/{str(old_id)}/", payload)
self.assertEqual(400, response.status_code)
payload["is_published"] = False
response = self.client.patch(f"/sublet/properties/{str(old_id)}/", payload)
self.assertEqual(200, response.status_code)
response = self.client.patch(f"/sublet/properties/{str(old_id)}/", {"is_published": True})
self.assertEqual(400, response.status_code)

def test_browse_sublets(self):
response = self.client.get("/sublet/properties/")
Expand Down

0 comments on commit 8e0d48d

Please sign in to comment.