@@ -199,3 +199,42 @@ def test_ip_allocate_ephemeral(self):
199199 assert "reserved" not in body
200200 assert ip .linode_id == 456
201201 assert ip .reserved is False
202+
203+ def test_ip_allocate_requires_linode_when_not_reserved (self ):
204+ """
205+ Tests that ip_allocate rejects ephemeral allocation without a linode.
206+ """
207+ with MethodMock ("post" , {}) as m :
208+ with self .assertRaises (ValueError ) as ctx :
209+ self .client .networking .ip_allocate ()
210+
211+ assert str (ctx .exception ) == (
212+ "linode is required when reserved is False."
213+ )
214+ assert m .called is False
215+
216+ def test_ip_allocate_requires_linode_or_region_when_reserved (self ):
217+ """
218+ Tests that ip_allocate rejects reserved allocation without a linode or region.
219+ """
220+ with MethodMock ("post" , {}) as m :
221+ with self .assertRaises (ValueError ) as ctx :
222+ self .client .networking .ip_allocate (reserved = True )
223+
224+ assert str (ctx .exception ) == (
225+ "Either linode or region must be provided when reserved is True."
226+ )
227+ assert m .called is False
228+
229+ def test_ip_allocate_rejects_region_when_not_reserved (self ):
230+ """
231+ Tests that ip_allocate rejects region when reserved is False.
232+ """
233+ with MethodMock ("post" , {}) as m :
234+ with self .assertRaises (ValueError ) as ctx :
235+ self .client .networking .ip_allocate (region = "us-east" , linode = 456 )
236+
237+ assert str (ctx .exception ) == (
238+ "region is only valid when reserved is True."
239+ )
240+ assert m .called is False
0 commit comments