Skip to content

Commit fdfc1ae

Browse files
committed
Re-enable test_delete from test_input.py
This also simplifies the test and splits it into to two separate tests.
1 parent c7e9f87 commit fdfc1ae

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

tests/integration/test_input.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -282,27 +282,32 @@ def test_update(self):
282282
entity.refresh()
283283
self.assertEqual(entity.host, kwargs["host"])
284284

285-
@pytest.mark.skip("flaky")
286285
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+
)
306311

307312

308313
if __name__ == "__main__":

0 commit comments

Comments
 (0)