Files
distcloud/distributedcloud/dccertmon/tests/base.py
Enzo Candotti 2fb911b015 Add unit tests for dccertmon
Introduce mocked unit tests to cover the core functionality of the
dccertmon service. These include tests migrated from the config
repository that previously validated subcloud certificate audits.

Additionally, this change adds dedicated tests for the Notification
Audit Queue, covering:
 - Enqueuing logic
 - Timestamp-based ordering
 - Requeuing on failure with delay
 - Concurrent audits from both queues
 - Lock enforcement when auditing the same subcloud

The unit test coverage for certificate_monitor_manager was improved
to 93%, and for subcloud_audit_queue to 97%.

Test Plan:
PASS: Successfully built distributedcloud package with these changes.
PASS: Run tox and verify that all tests pass.
PASS: All of the tests were created considering the output of 'tox -c
      tox.ini -e cover' command.

Story: 2011311
Task: 52181

Change-Id: I6b07d30c380cd9fee761f5f11876073ef9353645
Signed-off-by: Enzo Candotti <Enzo.Candotti@windriver.com>
2025-05-26 14:01:30 -03:00

31 lines
838 B
Python

#
# Copyright (c) 2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from oslo_config import cfg
from oslotest import base
from dccertmon.common import config
class DCCertMonTestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""
def setUp(self):
super().setUp()
config.register_config_opts()
cfg.CONF([], project="dccertmon", default_config_files=[])
cfg.CONF.set_override("auth_uri", "http://fake:5000/v3", group="endpoint_cache")
def _mock_object(self, target, attribute, wraps=None):
"""Mock a specified target's attribute and return the mock object"""
mock_patch_object = mock.patch.object(target, attribute, wraps=wraps)
self.addCleanup(mock_patch_object.stop)
return mock_patch_object.start()