@@ -596,6 +596,61 @@ def test_to_pascal_basic(self):
596596 self .assertEqual (client ._to_pascal ("single" ), "Single" )
597597
598598
599+ class TestPluralize (unittest .TestCase ):
600+ """Unit tests for _ODataClient._pluralize."""
601+
602+ def _p (self , word : str ) -> str :
603+ return _ODataClient ._pluralize (word )
604+
605+ # --- regular -s words ---
606+ def test_regular_word (self ):
607+ self .assertEqual (self ._p ("Product" ), "Products" )
608+
609+ def test_regular_word_account (self ):
610+ self .assertEqual (self ._p ("Account" ), "Accounts" )
611+
612+ # --- consonant + y → -ies ---
613+ def test_consonant_y_company (self ):
614+ self .assertEqual (self ._p ("Company" ), "Companies" )
615+
616+ def test_consonant_y_category (self ):
617+ self .assertEqual (self ._p ("Category" ), "Categories" )
618+
619+ def test_consonant_y_policy (self ):
620+ self .assertEqual (self ._p ("Policy" ), "Policies" )
621+
622+ # --- vowel + y → -ys (not -ies) ---
623+ def test_vowel_y_key (self ):
624+ self .assertEqual (self ._p ("Key" ), "Keys" )
625+
626+ def test_vowel_y_day (self ):
627+ self .assertEqual (self ._p ("Day" ), "Days" )
628+
629+ # --- -s / -x / -z / -ch / -sh → -es ---
630+ def test_s_ending (self ):
631+ self .assertEqual (self ._p ("Class" ), "Classes" )
632+
633+ def test_x_ending (self ):
634+ self .assertEqual (self ._p ("Box" ), "Boxes" )
635+
636+ def test_ch_ending (self ):
637+ self .assertEqual (self ._p ("Match" ), "Matches" )
638+
639+ def test_sh_ending (self ):
640+ self .assertEqual (self ._p ("Dish" ), "Dishes" )
641+
642+ # --- multi-word display names ---
643+ def test_multi_word (self ):
644+ self .assertEqual (self ._p ("Health Inspection" ), "Health Inspections" )
645+
646+ def test_multi_word_y (self ):
647+ self .assertEqual (self ._p ("Budget Category" ), "Budget Categories" )
648+
649+ # --- edge cases ---
650+ def test_empty_string (self ):
651+ self .assertEqual (self ._p ("" ), "" )
652+
653+
599654class TestRequestErrorParsing (unittest .TestCase ):
600655 """Unit tests for _ODataClient._request error response handling."""
601656
@@ -2908,7 +2963,7 @@ def test_display_name_defaults_to_schema_name(self):
29082963 self .assertEqual (body ["DisplayName" ]["LocalizedLabels" ][0 ]["Label" ], "new_TestTable" )
29092964
29102965 def test_display_collection_name_derived_from_display_name (self ):
2911- """_build_create_entity appends 's' to display_name for DisplayCollectionName."""
2966+ """_build_create_entity uses _pluralize( display_name) for DisplayCollectionName."""
29122967 body = self ._body (display_name = "Test Table" )
29132968 self .assertEqual (body ["DisplayCollectionName" ]["LocalizedLabels" ][0 ]["Label" ], "Test Tables" )
29142969
@@ -3020,8 +3075,8 @@ def test_display_collection_name_explicit(self):
30203075 body = json .loads (self .od ._build_create_entity ("new_TestTable" , {}, display_collection_name = "Test Tables" ).body )
30213076 self .assertEqual (body ["DisplayCollectionName" ]["LocalizedLabels" ][0 ]["Label" ], "Test Tables" )
30223077
3023- def test_display_collection_name_defaults_to_display_name_plus_s (self ):
3024- """_build_create_entity appends 's' to the label when display_collection_name is omitted."""
3078+ def test_display_collection_name_defaults_to_pluralized_label (self ):
3079+ """_build_create_entity uses _pluralize( label) when display_collection_name is omitted."""
30253080 body = self ._body (display_name = "Widget" )
30263081 self .assertEqual (body ["DisplayCollectionName" ]["LocalizedLabels" ][0 ]["Label" ], "Widgets" )
30273082
0 commit comments