@@ -95,6 +95,21 @@ def test_create_a_new_interest_by_organisation_admin_passes(self):
9595 self .assertEqual (response .status_code , 200 )
9696 self .assertEqual (response_body ["name" ], NEW_INTEREST_NAME )
9797
98+ def test_create_a_new_interest_with_empty_name_fails (self ):
99+ """
100+ Test that endpoint returns 400 when admin creates a new interest with empty name
101+ """
102+ # setup: make test user organisation admin
103+ add_manager_to_organisation (self .test_organisation , self .test_user )
104+ response = self .client .post (
105+ self .endpoint_url ,
106+ headers = {"Authorization" : self .session_token },
107+ json = {"name" : "" },
108+ )
109+ response_body = response .get_json ()
110+ self .assertEqual (response .status_code , 400 )
111+ self .assertEqual (response_body ["SubCode" ], "InvalidData" )
112+
98113 # get
99114 def test_get_all_interest_passes (self ):
100115 """
@@ -230,6 +245,21 @@ def test_update_an_existent_interest_with_invalid_data_fails(self):
230245 self .assertEqual (response .status_code , 400 )
231246 self .assertEqual (response_body ["SubCode" ], "InvalidData" )
232247
248+ def test_update_an_interest_with_empty_name_fails (self ):
249+ """
250+ Test that endpoint returns 400 when updating an interest with empty name
251+ """
252+ # setup: make test user organisation admin
253+ add_manager_to_organisation (self .test_organisation , self .test_user )
254+ response = self .client .patch (
255+ self .endpoint_url ,
256+ headers = {"Authorization" : self .session_token },
257+ json = {"name" : "" },
258+ )
259+ response_body = response .get_json ()
260+ self .assertEqual (response .status_code , 400 )
261+ self .assertEqual (response_body ["SubCode" ], "InvalidData" )
262+
233263 def test_update_an_existing_interest_by_organisation_admin_passes (self ):
234264 """
235265 Test that endpoint returns 200 when updating an existing interest by admin
0 commit comments