• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

reactive-firewall-org / multicast / 16583975596

22 Jul 2025 10:18PM UTC coverage: 27.998% (-69.1%) from 97.128%
16583975596

push

github

reactive-firewall
[FIX] Initial Tuning of over limited concurancy settings

Changes in file .github/workflows/CI-BUILD.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/CI-CHGLOG.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/CI-DOCS.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/CI-MATs.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/Tests.yml:
 * Removed limits (kept throttling)

Changes in file .github/workflows/bandit.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/codeql-analysis.yml:
 * Retuned limit for schedule runs

Changes in file .github/workflows/flake8.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/makefile-lint.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/markdown-lint.yml:
 * Removed limits reverting to previous LGV

Changes in file .github/workflows/scorecard.yml:
 * Retuned limit for schedule runs

Changes in file .github/workflows/shellcheck.yml:
 * Removed limits reverting to previous LGV

37 of 133 branches covered (27.82%)

Branch coverage included in aggregate %.

626 of 2235 relevant lines covered (28.01%)

0.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/tests/test_exceptions.py
1
#! /usr/bin/env python3
2
# -*- coding: utf-8 -*-
3

4
# Multicast Python Module
5
# ..................................
6
# Copyright (c) 2017-2025, Mr. Walls
7
# ..................................
8
# Licensed under MIT (the "License");
9
# you may not use this file except in compliance with the License.
10
# You may obtain a copy of the License at
11
# ..........................................
12
# https://github.com/reactive-firewall-org/multicast/tree/HEAD/LICENSE.md
13
# ..........................................
14
# Unless required by applicable law or agreed to in writing, software
15
# distributed under the License is distributed on an "AS IS" BASIS,
16
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
# See the License for the specific language governing permissions and
18
# limitations under the License.
19

20
__module__ = "tests"
×
21

22
try:
×
23
        """Handle imports with CWE-758 mitigation.
×
24

25
        This implementation uses a nested try-except pattern to:
26
        1. Attempt direct context import
27
        2. Fallback to relative import
28
        3. Validate context module integrity
29
        4. Import required dependencies
30

31
        References:
32
        - CWE-758: Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
33
        """
34
        try:
×
35
                import context
×
36
        except ImportError as _cause:  # pragma: no branch
37
                del _cause  # skipcq - cleanup any error vars early
38
                from . import context
39
        if not hasattr(context, '__name__') or not context.__name__:  # pragma: no branch
×
40
                raise ModuleNotFoundError("[CWE-758] Failed to import context") from None
41
        else:
42
                from context import multicast  # pylint: disable=cyclic-import - skipcq: PYL-R0401
×
43
                from context import unittest
×
44
                from context import BasicUsageTestSuite
×
45
except ImportError as baton:  # pragma: no branch
46
        raise ImportError("[CWE-758] Failed to import test context") from baton
47

48

49
@context.markWithMetaTag("mat", "bootstrap")
×
50
class ExceptionsTestSuite(BasicUsageTestSuite):
×
51
        """
52
        Test suite for validating the behavior of exception classes in the multicast package.
53

54
        This suite comprehensively tests both CommandExecutionError and ShutdownCommandReceived
55
        classes, verifying:
56
        - Initialization with various argument combinations
57
        - Default values and overrides
58
        - Exception chaining and cause propagation
59
        - Exit code handling and constraints
60

61
        The suite extends BasicUsageTestSuite to leverage common test infrastructure
62
        and maintain consistency across the test framework.
63
        """
64

65
        __module__ = "tests.test_exceptions"
×
66

67
        __name__ = "tests.test_exceptions.ExceptionsTestSuite"
×
68

69
        def test_command_execution_error_with_args(self) -> None:
×
70
                """
71
                Test CommandExecutionError initialization with custom message and exit code.
72

73
                Verifies that both the message and exit code are correctly assigned when
74
                explicitly provided during initialization.
75
                """
76
                error = multicast.exceptions.CommandExecutionError("Test error", 42)
×
77
                self.assertEqual(error.message, "Test error")
×
78
                self.assertEqual(error.exit_code, 42)
79

80
        def test_command_execution_error_default_exit_code(self) -> None:
81
                """Test CommandExecutionError initialization with default exit code.
82

83
                Verifies that the exit code defaults to 1 when only a message is provided.
84
                """
85
                error = multicast.exceptions.CommandExecutionError("Test error")
86
                self.assertEqual(error.exit_code, 1)
87

88
        def test_command_execution_error_with_cause(self) -> None:
×
89
                """Test CommandExecutionError initialization with a cause.
90

91
                Verifies that the error properly chains exceptions when initialized with a
92
                cause, maintaining both the cause reference and custom attributes.
93
                """
94
                test_cause = RuntimeError("test")
×
95
                self.assertIsNotNone(test_cause)
×
96
                error = multicast.exceptions.CommandExecutionError(test_cause, "Test with cause", 77)
×
97
                self.assertIsNotNone(error)
×
98
                self.assertIsNotNone(error.__cause__)
×
99
                self.assertEqual(error.__cause__, test_cause)
×
100
                self.assertEqual(error.message, "Test with cause")
×
101
                self.assertEqual(error.exit_code, 77)
102

103
        def test_shutdown_received_error_with_args(self) -> None:
×
104
                """
105
                Test ShutdownCommandReceived initialization with custom message and exit code.
106

107
                Verifies that both the message and exit code are correctly assigned when
108
                explicitly provided during initialization.
109
                """
110
                error = multicast.exceptions.ShutdownCommandReceived("Test Shutdown", 42)
×
111
                self.assertEqual(error.message, "Test Shutdown")
×
112
                self.assertNotEqual(error.exit_code, 42, "Unexpectedly was able to override exit code!")
113
                self.assertEqual(error.exit_code, 143)
114

115
        def test_shutdown_received_error_default_exit_code(self) -> None:
116
                """Test ShutdownCommandReceived initialization with default exit code.
117

118
                Verifies that the exit code defaults to 143 when only a message is provided.
119
                """
120
                error = multicast.exceptions.ShutdownCommandReceived("Test Shutdown")
121
                self.assertEqual(error.exit_code, 143)
122

123
        def test_shutdown_received_error_GIVEN_no_args(self) -> None:
×
124
                """Test ShutdownCommandReceived initialization with default exit code.
125

126
                Verifies that the exit code defaults to 143 when no arguments are provided.
127
                Verifies that the message defaults to 'SHUTDOWN' when no arguments are provided.
128
                """
129
                error = multicast.exceptions.ShutdownCommandReceived()
×
130
                self.assertEqual(error.message, "SHUTDOWN")
×
131
                self.assertEqual(error.exit_code, 143)
132

133
        def test_shutdown_received_error_with_cause(self) -> None:
×
134
                """Test ShutdownCommandReceived initialization with a cause.
135

136
                Verifies that the error properly chains exceptions when initialized with a
137
                cause, maintaining both the cause reference and custom attributes.
138
                """
139
                test_cause = RuntimeError("test")
×
140
                self.assertIsNotNone(test_cause)
×
141
                error = multicast.exceptions.ShutdownCommandReceived(test_cause, "Shutdown with cause", 77)
×
142
                self.assertIsNotNone(error)
×
143
                self.assertIsNotNone(error.__cause__)
×
144
                self.assertEqual(error.__cause__, test_cause)
×
145
                self.assertEqual(error.message, "Shutdown with cause")
×
146
                self.assertNotEqual(error.exit_code, 77, "Unexpectedly was able to override exit code!")
147
                self.assertEqual(error.exit_code, 143)
148

149
        def test_command_execution_error_with_bad_inputs(self) -> None:
×
150
                """Test CommandExecutionError handling of garbage inputs.
151

152
                Verifies that the class properly handles edge cases and invalid inputs
153
                by either raising appropriate exceptions or applying sensible defaults.
154
                """
155
                error = multicast.exceptions.CommandExecutionError(None)
×
156
                self.assertIsNotNone(error.message, "Unexpectedly was able to override None as message!")
×
157
                # Test with invalid cause type
158
                with self.assertRaises(TypeError):
×
159
                        multicast.exceptions.CommandExecutionError(__cause__=42, message="Test")
×
160

161
        def test_shutdown_received_error_scenarios(self) -> None:
×
162
                """Test ShutdownCommandReceived across multiple scenarios using parameterized tests."""
163
                test_cases = [
164
                        {
165
                                "name": "custom_message",
166
                                "args": ("Test Shutdown",),
167
                                "expected": {"message": "Test Shutdown", "exit_code": 143},
168
                        },
169
                        {
170
                                "name": "with_exit_code_override_attempt",
171
                                "args": ("Test Shutdown", 42),
172
                                "expected": {"message": "Test Shutdown", "exit_code": 143},
173
                        },
174
                        {
175
                                "name": "no_args",
176
                                "args": (),
177
                                "expected": {"message": "SHUTDOWN", "exit_code": 143},
178
                        },
179
                ]
180
                for case in test_cases:
×
181
                        with self.subTest(name=case["name"]):
×
182
                                error = multicast.exceptions.ShutdownCommandReceived(*case["args"])
×
183
                                self.assertIsNotNone(error)
×
184
                                self.assertIsNotNone(error.message)
×
185
                                self.assertEqual(error.message, case["expected"]["message"])
×
186
                                self.assertIsNotNone(error.exit_code)
187
                                self.assertEqual(error.exit_code, case["expected"]["exit_code"])
188

189

190
# leave this part
191
if __name__ == '__main__':
192
        unittest.main()
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc