@@ -1208,14 +1208,12 @@ def test_validation_error_list_format(self):
12081208
12091209
12101210# ---------------------------------------------------------------------------
1211- # DRFMutation / DRFDeletion IOSettings misconfiguration guard (issue #1360)
1211+ # DRFMutation / DRFDeletion IOSettings misconfiguration guard
12121212# ---------------------------------------------------------------------------
12131213
12141214
12151215class TestIOSettingsRequiredFieldsGuard (TestCase ):
1216- """Subclasses that forget to configure IOSettings should fail with a
1217- clear ``NotImplementedError`` rather than a late ``AttributeError`` /
1218- ``TypeError`` that pretends to be a generic "internal error"."""
1216+ """Misconfigured IOSettings must raise ``NotImplementedError`` at mutation time."""
12191217
12201218 def test_require_io_setting_raises_when_io_settings_missing (self ):
12211219 from config .graphql .base import _require_io_setting
@@ -1229,8 +1227,7 @@ class MisconfiguredMutation:
12291227 self .assertIn ("model" , str (ctx .exception ))
12301228
12311229 def test_require_io_setting_raises_when_attribute_none (self ):
1232- """Mirrors the inherited ``IOSettings`` on ``DRFMutation`` where
1233- ``model``/``serializer``/``graphene_model`` default to ``None``."""
1230+ """Each of model/serializer/graphene_model must independently fail when ``None``."""
12341231 from config .graphql .base import _require_io_setting
12351232
12361233 class MisconfiguredMutation :
@@ -1255,13 +1252,28 @@ class IOSettings:
12551252 self .assertIs (_require_io_setting (ConfiguredMutation , "model" ), Corpus )
12561253
12571254 def test_base_iosettings_defaults_are_none_on_mutation (self ):
1258- """Regression guard: the base ``DRFMutation.IOSettings`` exposes
1259- ``model`` / ``graphene_model`` / ``serializer`` as ``None`` so the
1260- runtime guard can detect a missing override. ``DRFDeletion`` now
1261- declares ``model`` the same way (previously not declared at all)."""
1255+ """Base ``IOSettings`` must default to ``None`` so the runtime guard can fire."""
12621256 from config .graphql .base import DRFDeletion , DRFMutation
12631257
12641258 self .assertIsNone (DRFMutation .IOSettings .model )
12651259 self .assertIsNone (DRFMutation .IOSettings .serializer )
12661260 self .assertIsNone (DRFMutation .IOSettings .graphene_model )
12671261 self .assertIsNone (DRFDeletion .IOSettings .model )
1262+
1263+ def test_drf_deletion_mutate_raises_when_lookup_value_missing (self ):
1264+ """``DRFDeletion.mutate`` must raise ``ValueError`` when the lookup arg is omitted."""
1265+ from unittest .mock import MagicMock
1266+
1267+ from config .graphql .base import DRFDeletion
1268+
1269+ class _DeleteCorpus (DRFDeletion ):
1270+ class IOSettings (DRFDeletion .IOSettings ):
1271+ model = Corpus
1272+ lookup_field = "id"
1273+
1274+ info = MagicMock ()
1275+ info .context .user = MagicMock (is_authenticated = True )
1276+
1277+ with self .assertRaises (ValueError ) as ctx :
1278+ _DeleteCorpus .mutate (None , info )
1279+ self .assertIn ("id" , str (ctx .exception ))
0 commit comments