From 71a73245083f0135aea2fb063fd3dd7332ff08e1 Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Wed, 17 Jan 2024 12:02:24 +0100 Subject: [PATCH] Fix network sorting in API tests There is a mismatch in some tests because sorted() sorts in ASCII order - digits are followed by uppercase characters and then lowercase characters. That doesn't work if a network's name starts with a capital letter. Closes-Bug: #2049211 Change-Id: I8328d7d8ca7b49b99feb24d77525abdc064aae80 --- neutron_tempest_plugin/api/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neutron_tempest_plugin/api/base.py b/neutron_tempest_plugin/api/base.py index e3c9aada8..28d556a91 100644 --- a/neutron_tempest_plugin/api/base.py +++ b/neutron_tempest_plugin/api/base.py @@ -1437,7 +1437,9 @@ class BaseSearchCriteriaTest(BaseNetworkTest): self.assertNotEmpty( resources, "%s list returned is empty" % self.resource) retrieved_names = [res[self.field] for res in resources] - expected = sorted(retrieved_names) + # sort without taking into account whether the network is named with + # a capital letter or not + expected = sorted(retrieved_names, key=lambda v: v.upper()) if direction == constants.SORT_DIRECTION_DESC: expected = list(reversed(expected)) self.assertEqual(expected, retrieved_names)