From f73d6eb1dc928c811231e059f293901405bed1ee Mon Sep 17 00:00:00 2001 From: John Garbutt Date: Wed, 18 Oct 2017 11:47:49 +0100 Subject: [PATCH] Add test so we remember why CUSTOM_ prefix added While it is tempting as an ironic operator to have CUSTOM_FOO in placement, nova flavors and ironic resource class attributes, allow that makes for a more complicated mapping between ironic resource classes and the resource classes in the general case, and could cause confusion when there is a typo of CUSTOM vs CUSTM that could get mapped very differently into placement. Adding this test so it is clear this is a deliberate choice, and git blame will find this git commit message. Related-Bug: #1724524 Change-Id: Ie38baea53e41ca7ba8875fd113cd777810f17db7 --- nova/tests/unit/objects/test_fields.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nova/tests/unit/objects/test_fields.py b/nova/tests/unit/objects/test_fields.py index 3d0d786fa10b..d0d977e603f7 100644 --- a/nova/tests/unit/objects/test_fields.py +++ b/nova/tests/unit/objects/test_fields.py @@ -351,6 +351,17 @@ class TestResourceClass(TestString): self.to_primitive_values = self.coerce_good_values[0:1] self.from_primitive_values = self.coerce_good_values[0:1] + def test_normalize_name(self): + values = [ + ("foo", "CUSTOM_FOO"), + ("VCPU", "CUSTOM_VCPU"), + ("CUSTOM_BOB", "CUSTOM_CUSTOM_BOB"), + ("CUSTM_BOB", "CUSTOM_CUSTM_BOB"), + ] + for test_value, expected in values: + result = fields.ResourceClass.normalize_name(test_value) + self.assertEqual(expected, result) + class TestInteger(TestField): def setUp(self):