Add test for quiet processor option
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
parent
233d63077e
commit
9304d1b30e
1 changed files with 17 additions and 0 deletions
|
@ -12,6 +12,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import contextlib
|
||||
from io import StringIO
|
||||
from typing import Dict
|
||||
from typing import Set
|
||||
import unittest
|
||||
|
@ -172,6 +174,21 @@ class TestProcessor(unittest.TestCase):
|
|||
result = processor.get_handler_by_type(StubHandler1)
|
||||
self.assertTrue(result is handler1)
|
||||
|
||||
def test_processor_quiet(self) -> None:
|
||||
handler1 = StubHandler1()
|
||||
mock_event = {
|
||||
'_name': 'myeventname',
|
||||
'_timestamp': 0,
|
||||
'cpu_id': 0,
|
||||
}
|
||||
temp_stdout = StringIO()
|
||||
with contextlib.redirect_stdout(temp_stdout):
|
||||
processor = Processor(handler1, quiet=True)
|
||||
processor.process([mock_event])
|
||||
# Shouldn't be any output
|
||||
output = temp_stdout.getvalue()
|
||||
self.assertEqual(0, len(output), f'Processor was not quiet: "{output}"')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue