Merge branch 'cnfvar-deprecations'
[pyi2ncommon] / test / test_arnied_wrapper.py
index da6ddb0..2e2476e 100755 (executable)
@@ -41,30 +41,6 @@ class DummyCmdOutputMapping:
     # whether to return 1 as a fail indicator
     fail_switch = False
     # mapping between expected commands and their mocked output + return code
-    cmds = [
-        {"cmd": "pgrep -l -x arnied", "stdout": b"", "returncode": 0},
-
-        {"cmd": 'echo "LICENSE_ACCEPTED,0: \\"1\\"" | set_cnf', "stdout": b"", "returncode": 0},
-        {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE', "stdout": b"", "returncode": 0},
-
-        {"cmd": 'get_cnf PROVIDER 1', "stdout": b"1  PROVIDER,1: \"sample-provider\"", "returncode": 0},
-        {"cmd": 'tell-connd --online P1', "stdout": b"", "returncode": 0},
-        {"cmd": '/usr/intranator/bin/get_var ONLINE', "stdout": b"DEFAULT: 2", "returncode": 0},
-
-        {"cmd": "pgrep -l -x arnied", "stdout": b"", "returncode": 0},
-        {"cmd": 'get_cnf VIRSCAN_UPDATE_CRON  | set_cnf -x', "stdout": b"", "returncode": 0},
-        {"cmd": '/usr/intranator/bin/arnied_helper --is-scheduled-or-running GENERATE', "stdout": b"", "returncode": 1},
-        {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE --wait-for-program-timeout 300', "stdout": b"", "returncode": 1},
-        {"cmd": '/usr/intranator/bin/arnied_helper --is-scheduled-or-running GENERATE_OFFLINE', "stdout": b"", "returncode": 1},
-        {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE_OFFLINE --wait-for-program-timeout 300', "stdout": b"", "returncode": 1},
-        {"cmd": 'echo \'VIRSCAN_UPDATE_DNS_PUSH,0:"0"\' |set_cnf', "stdout": b"", "returncode": 0},
-        {"cmd": 'rm -f /var/intranator/schedule/UPDATE_VIRSCAN_NODIAL*', "stdout": b"", "returncode": 0},
-
-        {"cmd": '/usr/intranator/bin/arnied_helper --transfer-mail', "stdout": b"", "returncode": 0},
-
-        {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-arnied-socket --wait-for-arnied-socket-timeout 10', "stdout": b"", "returncode": 0},
-        {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-arnied-socket --wait-for-arnied-socket-timeout 30', "stdout": b"", "returncode": 0},
-    ]
     asserted_cmds = []
 
     def __init__(self, cmd="", ignore_errors=False, vm=None, timeout=60):
@@ -108,11 +84,10 @@ class ArniedWrapperTest(unittest.TestCase):
     def setUp(self):
         DummyCmdOutputMapping.fail_switch = False
         DummyCmdOutputMapping.asserted_cmds = []
-        self.cmd_db = DummyCmdOutputMapping.cmds
 
     def test_verify_running(self):
         """Test checking for running programs."""
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[0:1]
+        DummyCmdOutputMapping.asserted_cmds = [{"cmd": "pgrep -l -x arnied", "stdout": b"", "returncode": 0}]
         arnied_wrapper.verify_running(timeout=1)
         DummyCmdOutputMapping.fail_switch = True
         with self.assertRaises(RuntimeError):
@@ -120,28 +95,15 @@ class ArniedWrapperTest(unittest.TestCase):
 
     def test_wait_for_arnied(self):
         """Test waiting for arnied to be ready."""
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db
+        DummyCmdOutputMapping.asserted_cmds = [{"cmd": "/usr/intranator/bin/arnied_helper --wait-for-arnied-socket --wait-for-arnied-socket-timeout 10", "stdout": b"", "returncode": 0}]
         arnied_wrapper.wait_for_arnied(timeout=10)
 
-    def test_accept_license(self):
-        """Test accepting license."""
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[1:3] + self.cmd_db[8:11]
-        arnied_wrapper.accept_licence()
-        # make sure an error is ignored since license might
-        # already be accepted
-        DummyCmdOutputMapping.fail_switch = True
-        arnied_wrapper.accept_licence()
-
     def test_go_online(self):
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[3:6]
+        DummyCmdOutputMapping.asserted_cmds = [{"cmd": 'tell-connd --online P1', "stdout": b"", "returncode": 0},
+                                               {"cmd": '/usr/intranator/bin/get_var ONLINE', "stdout": b"DEFAULT: 2", "returncode": 0}]
         arnied_wrapper.go_online(1)
 
-    def test_disable_virscan(self):
-        """Test disabling the virus scanner."""
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[6:]
-        arnied_wrapper.disable_virscan()
-
     def test_email_transfer(self):
         """Test e-mail transferring."""
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[14:15]
+        DummyCmdOutputMapping.asserted_cmds = [{"cmd": '/usr/intranator/bin/arnied_helper --transfer-mail', "stdout": b"", "returncode": 0}]
         arnied_wrapper.email_transfer()