summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oslo_config/tests/test_types.py29
-rw-r--r--oslo_config/types.py29
2 files changed, 54 insertions, 4 deletions
diff --git a/oslo_config/tests/test_types.py b/oslo_config/tests/test_types.py
index 666a11f..13ac650 100644
--- a/oslo_config/tests/test_types.py
+++ b/oslo_config/tests/test_types.py
@@ -856,6 +856,35 @@ class URITypeTests(TypeTestHelper, unittest.TestCase):
self.assertConvertedValue('http://www.example.com',
'http://www.example.com')
+ def test_equality(self):
+ a = types.URI()
+ b = types.URI()
+ self.assertEqual(a, b)
+
+ def test_equality_length(self):
+ a = types.URI(max_length=5)
+ b = types.URI(max_length=5)
+ self.assertEqual(a, b)
+
+ def test_equality_length_not(self):
+ a = types.URI()
+ b = types.URI(max_length=5)
+ c = types.URI(max_length=10)
+ self.assertNotEqual(a, b)
+ self.assertNotEqual(c, b)
+
+ def test_equality_schemes(self):
+ a = types.URI(schemes=['ftp'])
+ b = types.URI(schemes=['ftp'])
+ self.assertEqual(a, b)
+
+ def test_equality_schemes_not(self):
+ a = types.URI()
+ b = types.URI(schemes=['ftp'])
+ c = types.URI(schemes=['http'])
+ self.assertNotEqual(a, b)
+ self.assertNotEqual(c, b)
+
class PortTypeTests(TypeTestHelper, unittest.TestCase):
type = types.Port()
diff --git a/oslo_config/types.py b/oslo_config/types.py
index 06a81dd..74242c1 100644
--- a/oslo_config/types.py
+++ b/oslo_config/types.py
@@ -25,6 +25,7 @@ import re
import warnings
import abc
+from debtcollector import removals
import netaddr
import rfc3986
import six
@@ -891,17 +892,37 @@ class URI(ConfigType):
raise ValueError("URI scheme '%s' not in %s" %
(scheme, self.schemes))
- self.value = value
+ # NOTE(dhellmann): self.value is deprecated, and we don't want
+ # to trigger a deprecation warning ourselves so we modify
+ # self._value directly.
+ self._value = value
return value
+ @removals.removed_property
+ def value(self):
+ return self._value
+
+ @value.setter
+ def value(self, newval):
+ self._value = newval
+
+ @value.deleter
+ def value(self):
+ del self._value
+
def __repr__(self):
return 'URI'
def __eq__(self, other):
- return (
- (self.__class__ == other.__class__) and
- (self.value == other.value)
+ to_compare = ['__class__', 'max_length', 'schemes']
+ unset = object()
+ my_values = tuple(
+ getattr(self, name, unset) for name in to_compare
+ )
+ other_values = tuple(
+ getattr(other, name, unset) for name in to_compare
)
+ return my_values == other_values
def _formatter(self, value):
return value