From 16a6bb4f8ad1eb7c044ece9600e9d775a23ac18d Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Thu, 18 Apr 2024 08:08:00 -0700 Subject: [PATCH] Remove duplicative sort and add a more robust test. --- octodns/processor/arpa.py | 2 +- tests/test_octodns_processor_arpa.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/octodns/processor/arpa.py b/octodns/processor/arpa.py index 3b98761..bd56ec9 100644 --- a/octodns/processor/arpa.py +++ b/octodns/processor/arpa.py @@ -51,8 +51,8 @@ class AutoArpa(BaseProcessor): return desired def _order_and_unique_fqdns(self, fqdns, max_auto_arpa): - fqdns = sorted(fqdns) seen = set() + # order the fqdns making a copy so we can reset the list below ordered = sorted(fqdns) fqdns = [] for _, fqdn in ordered: diff --git a/tests/test_octodns_processor_arpa.py b/tests/test_octodns_processor_arpa.py index ccdb70f..328d05f 100644 --- a/tests/test_octodns_processor_arpa.py +++ b/tests/test_octodns_processor_arpa.py @@ -281,6 +281,23 @@ class TestAutoArpa(TestCase): aa._order_and_unique_fqdns(duplicate_values, max_auto_arpa=999), ) + duplicate_values = [ + (50, 'd.unit.tests.'), + (999, 'dup.unit.tests.'), + (3, 'a.unit.tests.'), + (1, 'dup.unit.tests.'), + (2, 'c.unit.tests.'), + ] + self.assertEqual( + [ + 'dup.unit.tests.', + 'c.unit.tests.', + 'a.unit.tests.', + 'd.unit.tests.', + ], + aa._order_and_unique_fqdns(duplicate_values, max_auto_arpa=999), + ) + duplicate_values_2 = [(999, 'a.unit.tests.'), (999, 'a.unit.tests.')] self.assertEqual( ['a.unit.tests.'],