Debian Codegraph @

ansible_collections/dellemc/openmanage/tests/unit/plugins/module_utils/test_logging_handler.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3
4 # Dell OpenManage Ansible Modules
5 # Version 10.0.1
6 # Copyright (C) 2025 Dell Inc.
7
8 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # All rights reserved. Dell, EMC, and other trademarks are trademarks of Dell Inc. or its subsidiaries.
10 # Other trademarks may be trademarks of their respective owners.
11
12
13 from datetime import datetime
14 from ansible_collections.dellemc.openmanage.plugins.module_utils.logging_handler import CustomRotatingFileHandler
15 import tempfile
16 import os
17
18
19 def test_rotation_filename_format():
20 with tempfile.TemporaryDirectory() as tmpdir:
21 log_path = os.path.join(tmpdir, "test.log")
22 handler = CustomRotatingFileHandler(log_path, maxBytes=1000, backupCount=1)
23 default_name = "test.log.1"
24
25 rotated_name = handler.rotation_filename(default_name)
26
27 expected_date = datetime.now().strftime("%Y%m%d")
28 assert rotated_name.startswith(f"test_{expected_date}.log.1")