Fix object tests
A couple of object tests are failing, probably after a dependency
bump.
watcher.objects.base.objects is mocked, so the registered object
version isn't properly retrieved, leading to a type error:
File "/mnt/data/workspace/watcher/watcher/tests/objects/test_objects.py",
line 535, in test_hook_chooses_newer_properly
reg.registration_hook(MyObj, 0)
File "/mnt/data/workspace/watcher/watcher/objects/base.py",
line 46, in registration_hook
cur_version = versionutils.convert_version_to_tuple(
File "/home/ubuntu/openstack_venv/lib/python3.10/site-packages/oslo_utils/versionutils.py",
line 91, in convert_version_to_tuple
version_str = re.sub(r'(\d+)(a|alpha|b|beta|rc)\d+$', '\\1', version_str)
File "/usr/lib/python3.10/re.py", line 209, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
We'll solve the issue by setting the VERSION attribute against
the mock object.
Change-Id: Ifeb38b98f1d702908531de5fc5c846bd1c53de4b
This commit is contained in:
@@ -531,6 +531,7 @@ class TestRegistry(test_base.TestCase):
|
|||||||
|
|
||||||
@mock.patch('watcher.objects.base.objects')
|
@mock.patch('watcher.objects.base.objects')
|
||||||
def test_hook_chooses_newer_properly(self, mock_objects):
|
def test_hook_chooses_newer_properly(self, mock_objects):
|
||||||
|
mock_objects.MyObj.VERSION = MyObj.VERSION
|
||||||
reg = base.WatcherObjectRegistry()
|
reg = base.WatcherObjectRegistry()
|
||||||
reg.registration_hook(MyObj, 0)
|
reg.registration_hook(MyObj, 0)
|
||||||
|
|
||||||
@@ -547,6 +548,7 @@ class TestRegistry(test_base.TestCase):
|
|||||||
|
|
||||||
@mock.patch('watcher.objects.base.objects')
|
@mock.patch('watcher.objects.base.objects')
|
||||||
def test_hook_keeps_newer_properly(self, mock_objects):
|
def test_hook_keeps_newer_properly(self, mock_objects):
|
||||||
|
mock_objects.MyObj.VERSION = MyObj.VERSION
|
||||||
reg = base.WatcherObjectRegistry()
|
reg = base.WatcherObjectRegistry()
|
||||||
reg.registration_hook(MyObj, 0)
|
reg.registration_hook(MyObj, 0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user