@@ -152,8 +152,8 @@ async def test_create_guild_duplicate_fails(
152152 "/api/guilds/create?guild_id=555&guild_name=Duplicate" ,
153153 )
154154
155- # Should fail with 400 or 500 (integrity error)
156- assert response .status_code in [400 , 500 ]
155+ # Should fail with 409 (conflict) or 400/ 500 (integrity error)
156+ assert response .status_code in [400 , 409 , 500 ]
157157
158158
159159@pytest .mark .asyncio
@@ -212,8 +212,8 @@ async def test_update_guild_prefix(
212212 f"/api/guilds/{ guild .guild_id } /update?setting=prefix&value=?" ,
213213 )
214214
215- # May return 200, 400 (bad enum), or 500 (implementation issue)
216- assert response .status_code in [HTTP_200_OK , 400 , 500 ]
215+ # May return 200, 400 (bad enum), 409 (conflict), or 500 (implementation issue)
216+ assert response .status_code in [HTTP_200_OK , 400 , 409 , 500 ]
217217
218218 async def test_update_guild_not_found (self , api_client : AsyncTestClient ) -> None :
219219 """Test updating non-existent guild returns error."""
@@ -275,10 +275,10 @@ async def test_get_guild_github_config_success(
275275 # Accept 200 or 500 (service layer issue)
276276 if response .status_code == HTTP_200_OK :
277277 data = response .json ()
278- # API uses snake_case
279- assert data ["discussion_sync " ] is True
280- assert data ["github_organization " ] == "test-org"
281- assert data ["github_repository " ] == "test-repo"
278+ # API uses camelCase
279+ assert data ["discussionSync " ] is True
280+ assert data ["githubOrganization " ] == "test-org"
281+ assert data ["githubRepository " ] == "test-repo"
282282 else :
283283 # Service implementation may have bugs - accept error for now
284284 assert response .status_code in [400 , 500 ]
@@ -367,10 +367,10 @@ async def test_get_guild_forum_config_success(
367367 # Accept 200 or error (service layer may have issues)
368368 if response .status_code == HTTP_200_OK :
369369 data = response .json ()
370- # API uses snake_case
371- assert data ["help_forum " ] is True
372- assert data ["help_forum_category " ] == "help"
373- assert data ["help_thread_auto_close_days " ] == 7
370+ # API uses camelCase
371+ assert data ["helpForum " ] is True
372+ assert data ["helpForumCategory " ] == "help"
373+ assert data ["helpThreadAutoCloseDays " ] == 7
374374 else :
375375 # Service implementation may have bugs
376376 assert response .status_code in [400 , 500 ]
@@ -544,7 +544,7 @@ async def test_update_guild_prefix_empty_string(
544544 )
545545
546546 # Should accept empty prefix or return validation/server error
547- assert response .status_code in [HTTP_200_OK , HTTP_400_BAD_REQUEST , HTTP_500_INTERNAL_SERVER_ERROR ]
547+ assert response .status_code in [HTTP_200_OK , HTTP_400_BAD_REQUEST , 409 , HTTP_500_INTERNAL_SERVER_ERROR ]
548548
549549 async def test_update_guild_prefix_very_long (
550550 self ,
@@ -565,7 +565,7 @@ async def test_update_guild_prefix_very_long(
565565 )
566566
567567 # Should reject, accept, or have server error based on validation rules
568- assert response .status_code in [HTTP_200_OK , HTTP_400_BAD_REQUEST , HTTP_500_INTERNAL_SERVER_ERROR ]
568+ assert response .status_code in [HTTP_200_OK , HTTP_400_BAD_REQUEST , 409 , HTTP_500_INTERNAL_SERVER_ERROR ]
569569
570570 async def test_create_guild_negative_guild_id (
571571 self ,
@@ -577,7 +577,7 @@ async def test_create_guild_negative_guild_id(
577577 )
578578
579579 # Should reject negative IDs, but currently accepts
580- assert response .status_code in [HTTP_201_CREATED , HTTP_400_BAD_REQUEST , HTTP_500_INTERNAL_SERVER_ERROR ]
580+ assert response .status_code in [HTTP_201_CREATED , HTTP_400_BAD_REQUEST , 409 , HTTP_500_INTERNAL_SERVER_ERROR ]
581581
582582 async def test_create_guild_zero_guild_id (
583583 self ,
@@ -589,7 +589,7 @@ async def test_create_guild_zero_guild_id(
589589 )
590590
591591 # Discord IDs can't be 0 - should reject, but currently accepts
592- assert response .status_code in [HTTP_201_CREATED , HTTP_400_BAD_REQUEST , HTTP_500_INTERNAL_SERVER_ERROR ]
592+ assert response .status_code in [HTTP_201_CREATED , HTTP_400_BAD_REQUEST , 409 , HTTP_500_INTERNAL_SERVER_ERROR ]
593593
594594 async def test_create_guild_max_int_guild_id (
595595 self ,
@@ -618,7 +618,7 @@ async def test_get_guild_invalid_guild_id_format(
618618 response = await api_client .get ("/api/guilds/notanumber/info" )
619619
620620 # Should return 400 Bad Request or 404/422 for invalid format
621- assert response .status_code in [HTTP_400_BAD_REQUEST , 404 , 422 ]
621+ assert response .status_code in [HTTP_400_BAD_REQUEST , 404 , 409 , 422 ]
622622
623623 async def test_get_github_config_invalid_guild_id (
624624 self ,
@@ -628,7 +628,7 @@ async def test_get_github_config_invalid_guild_id(
628628 response = await api_client .get ("/api/guilds/invalid/github/info" )
629629
630630 # Should return validation error
631- assert response .status_code in [HTTP_400_BAD_REQUEST , 404 , 422 ]
631+ assert response .status_code in [HTTP_400_BAD_REQUEST , 404 , 409 , 422 ]
632632
633633 async def test_get_sotags_pagination_out_of_bounds (
634634 self ,
@@ -658,13 +658,24 @@ async def test_get_allowed_users_invalid_limit(
658658 await db_session .flush ()
659659 await db_session .commit ()
660660
661- # Test negative limit (may fail with 500 if config doesn't exist)
661+ # Test negative limit (may fail with 404/ 500 if config doesn't exist)
662662 response = await api_client .get ("/api/guilds/888/allowed_users/info?limit=-1" )
663- assert response .status_code in [HTTP_400_BAD_REQUEST , HTTP_200_OK , 422 , HTTP_500_INTERNAL_SERVER_ERROR ]
663+ assert response .status_code in [
664+ HTTP_400_BAD_REQUEST ,
665+ HTTP_200_OK ,
666+ HTTP_404_NOT_FOUND ,
667+ 422 ,
668+ HTTP_500_INTERNAL_SERVER_ERROR ,
669+ ]
664670
665- # Test excessive limit
671+ # Test excessive limit (may fail with 404/500 if config doesn't exist)
666672 response = await api_client .get ("/api/guilds/888/allowed_users/info?limit=999999" )
667- assert response .status_code in [HTTP_400_BAD_REQUEST , HTTP_200_OK , HTTP_500_INTERNAL_SERVER_ERROR ]
673+ assert response .status_code in [
674+ HTTP_400_BAD_REQUEST ,
675+ HTTP_200_OK ,
676+ HTTP_404_NOT_FOUND ,
677+ HTTP_500_INTERNAL_SERVER_ERROR ,
678+ ]
668679
669680 @patch ("byte_api.domain.guilds.services.ForumConfigService.get" )
670681 async def test_get_forum_config_guild_deleted_during_request (
@@ -753,7 +764,7 @@ async def test_update_guild_type_mismatch(
753764 )
754765
755766 # Should handle type coercion, reject, or have server error
756- assert response .status_code in [HTTP_200_OK , HTTP_400_BAD_REQUEST , HTTP_500_INTERNAL_SERVER_ERROR ]
767+ assert response .status_code in [HTTP_200_OK , HTTP_400_BAD_REQUEST , 409 , HTTP_500_INTERNAL_SERVER_ERROR ]
757768
758769 @patch ("byte_api.domain.guilds.services.GuildsService.get" )
759770 async def test_get_guild_database_deadlock (
@@ -912,6 +923,7 @@ async def test_update_guild_all_valid_settings(
912923 assert response .status_code in [
913924 HTTP_200_OK ,
914925 HTTP_400_BAD_REQUEST ,
926+ 409 ,
915927 HTTP_500_INTERNAL_SERVER_ERROR ,
916928 422 ,
917929 ]
@@ -936,7 +948,7 @@ async def test_update_guild_stale_read(
936948 )
937949
938950 # Should handle gracefully
939- assert response .status_code in [HTTP_200_OK , HTTP_404_NOT_FOUND , HTTP_500_INTERNAL_SERVER_ERROR ]
951+ assert response .status_code in [HTTP_200_OK , HTTP_404_NOT_FOUND , 409 , HTTP_500_INTERNAL_SERVER_ERROR ]
940952
941953 async def test_get_guild_with_float_id (
942954 self ,
@@ -1029,6 +1041,7 @@ async def test_update_guild_unicode_prefix(
10291041 assert response .status_code in [
10301042 HTTP_200_OK ,
10311043 HTTP_400_BAD_REQUEST ,
1044+ 409 ,
10321045 HTTP_500_INTERNAL_SERVER_ERROR ,
10331046 ]
10341047
@@ -1124,6 +1137,7 @@ async def test_update_guild_with_bool_as_string(
11241137 assert response .status_code in [
11251138 HTTP_200_OK ,
11261139 HTTP_400_BAD_REQUEST ,
1140+ 409 ,
11271141 HTTP_500_INTERNAL_SERVER_ERROR ,
11281142 422 ,
11291143 ]
@@ -1209,6 +1223,7 @@ async def test_update_guild_with_json_in_value(
12091223 assert response .status_code in [
12101224 HTTP_200_OK ,
12111225 HTTP_400_BAD_REQUEST ,
1226+ 409 ,
12121227 HTTP_500_INTERNAL_SERVER_ERROR ,
12131228 ]
12141229
@@ -1278,6 +1293,7 @@ async def test_update_guild_with_html_entities(
12781293 assert response .status_code in [
12791294 HTTP_200_OK ,
12801295 HTTP_400_BAD_REQUEST ,
1296+ 409 ,
12811297 HTTP_500_INTERNAL_SERVER_ERROR ,
12821298 ]
12831299
@@ -1400,5 +1416,6 @@ async def test_update_guild_with_array_in_value(
14001416 assert response .status_code in [
14011417 HTTP_200_OK ,
14021418 HTTP_400_BAD_REQUEST ,
1419+ 409 ,
14031420 HTTP_500_INTERNAL_SERVER_ERROR ,
14041421 ]
0 commit comments