From 5c4142a828757ed4917a325c8dd508b9e2bafdaa Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 4 Oct 2023 21:29:24 +0100 Subject: [PATCH] Add a test for adding duplicates that don't yet exist --- tests/option_list/test_option_list_create.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/option_list/test_option_list_create.py b/tests/option_list/test_option_list_create.py index 88cdbd39a1..3310579b81 100644 --- a/tests/option_list/test_option_list_create.py +++ b/tests/option_list/test_option_list_create.py @@ -138,3 +138,18 @@ async def test_create_with_duplicate_id_and_subsequent_non_dupes() -> None: assert option_list.option_count == 6 option_list.add_option(Option("Not a dupe", id="7")) assert option_list.option_count == 7 + + +async def test_adding_multiple_duplicates_at_once() -> None: + """Adding duplicates together than aren't existing duplicates should be an error.""" + async with OptionListApp().run_test() as pilot: + option_list = pilot.app.query_one(OptionList) + assert option_list.option_count == 5 + with pytest.raises(DuplicateID): + option_list.add_options( + [ + Option("dupe", id="42"), + Option("dupe", id="42"), + ] + ) + assert option_list.option_count == 5