]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
tests: execute: Check if logger returned the correct output
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Jul 2022 10:23:15 +0000 (10:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Jul 2022 10:23:15 +0000 (10:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/python/execute.py

index 900d87aae6c87294d78120052446e588cfed2661..8c2cc27cb569f60e8e859092c0a4bee0e54a7f88 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 
+import logging
 import os
 import pakfire
 import unittest
@@ -77,9 +78,13 @@ class Test(unittest.TestCase):
 
        def test_execute_logger(self):
                def log(priority, message):
-                       print("LOG (%s): %s" % (priority, message.rstrip()))
+                       # Priority must be INFO
+                       self.assertEqual(priority, logging.INFO)
 
-               self.pakfire.execute(["/command", "lines", "10"], logging_callback=log)
+                       # All lines must be 20 characters long
+                       self.assertEqual(len(message), 20)
+
+               self.pakfire.execute(["/command", "lines", "10", "20"], logging_callback=log)
 
        # This is an interactive test which cannot be performed automatically
        #def test_shell(self):