Skip to content
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 backend/models/dtos/interests_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class InterestDTO(Model):
"""DTO for a interest."""

id = IntType()
name = StringType()
name = StringType(required=True, min_length=1)
user_selected = BooleanType(
serialized_name="userSelected", serialize_when_none=False
)
Expand Down
30 changes: 30 additions & 0 deletions tests/backend/integration/api/interests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ def test_create_a_new_interest_by_organisation_admin_passes(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(response_body["name"], NEW_INTEREST_NAME)

def test_create_a_new_interest_with_empty_name_fails(self):
"""
Test that endpoint returns 400 when admin creates a new interest with empty name
"""
# setup: make test user organisation admin
add_manager_to_organisation(self.test_organisation, self.test_user)
response = self.client.post(
self.endpoint_url,
headers={"Authorization": self.session_token},
json={"name": ""},
)
response_body = response.get_json()
self.assertEqual(response.status_code, 400)
self.assertEqual(response_body["SubCode"], "InvalidData")

# get
def test_get_all_interest_passes(self):
"""
Expand Down Expand Up @@ -230,6 +245,21 @@ def test_update_an_existent_interest_with_invalid_data_fails(self):
self.assertEqual(response.status_code, 400)
self.assertEqual(response_body["SubCode"], "InvalidData")

def test_update_an_interest_with_empty_name_fails(self):
"""
Test that endpoint returns 400 when updating an interest with empty name
"""
# setup: make test user organisation admin
add_manager_to_organisation(self.test_organisation, self.test_user)
response = self.client.patch(
self.endpoint_url,
headers={"Authorization": self.session_token},
json={"name": ""},
)
response_body = response.get_json()
self.assertEqual(response.status_code, 400)
self.assertEqual(response_body["SubCode"], "InvalidData")

def test_update_an_existing_interest_by_organisation_admin_passes(self):
"""
Test that endpoint returns 200 when updating an existing interest by admin
Expand Down