@@ -282,27 +282,32 @@ def test_update(self):
282
282
entity .refresh ()
283
283
self .assertEqual (entity .host , kwargs ["host" ])
284
284
285
- @pytest .mark .skip ("flaky" )
286
285
def test_delete (self ):
287
- inputs = self .service .inputs
288
- remaining = len (self ._test_entities ) - 1
289
- for input_entity in self ._test_entities .values ():
290
- name = input_entity .name
291
- kind = input_entity .kind
292
- self .assertTrue (name in inputs )
293
- self .assertTrue ((name , kind ) in inputs )
294
- if remaining == 0 :
295
- inputs .delete (name )
296
- self .assertFalse (name in inputs )
297
- else :
298
- if not name .startswith ("boris" ):
299
- self .assertRaises (
300
- client .AmbiguousReferenceException , inputs .delete , name
301
- )
302
- self .service .inputs .delete (name , kind )
303
- self .assertFalse ((name , kind ) in inputs )
304
- self .assertRaises (client .HTTPError , input_entity .refresh )
305
- remaining -= 1
286
+ udpName , udpKind = (
287
+ self ._test_entities ["udp" ].name ,
288
+ self ._test_entities ["udp" ].kind ,
289
+ )
290
+ tcpName , tcpKind = (
291
+ self ._test_entities ["tcp" ].name ,
292
+ self ._test_entities ["tcp" ].kind ,
293
+ )
294
+
295
+ self ._test_entities ["tcp" ].delete ()
296
+ self .service .inputs .delete (udpName , udpKind )
297
+
298
+ for input in self .service .inputs :
299
+ if input .name == tcpName and input .kind == tcpKind :
300
+ self .fail (f"{ tcpName } { tcpKind } still exists" )
301
+ if input .name == udpName and input .kind == udpKind :
302
+ self .fail (f"{ udpName } { udpKind } still exists" )
303
+
304
+ def test_delete_ambiguous_reference (self ):
305
+ # _test_entities["udp"] and _test_entities["tcp"] share the same input name, thus
306
+ # deletion only with the name, without specifying the input kind, should fail.
307
+ name = self ._test_entities ["udp" ].name
308
+ self .assertRaises (
309
+ client .AmbiguousReferenceException , lambda : self .service .inputs .delete (name )
310
+ )
306
311
307
312
308
313
if __name__ == "__main__" :
0 commit comments