Fix unit tests
authorSamir Aguiar <samir.aguiar@intra2net.com>
Wed, 1 Sep 2021 01:23:04 +0000 (22:23 -0300)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 10 Sep 2021 11:57:58 +0000 (13:57 +0200)
The dummy provider CNF variable was not in the correct form.

Also drop the TODO regarding raising an error when failing to go
online. The `run_cmd` function, which is mocked in the unit tests,
does check for the exit code of commands before returning.

test/test_arnied_wrapper.py

index 010fc30..ea41e82 100755 (executable)
@@ -36,8 +36,9 @@ class DummyCmdOutputMapping(object):
         {"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"PRODIVER 1, 'sample-provider'", "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},
@@ -96,18 +97,13 @@ class ArniedWrapperTest(unittest.TestCase):
         arnied_wrapper.accept_licence()
 
     def test_go_online(self):
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[3:5]
+        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[3:6]
         arnied_wrapper.go_online(1)
-        # TODO: for some reason failing to go online doesn't raise
-        # an error which could be very misleading during debugging
-        # DummyCmdOutputMapping.fail_switch = True
-        # with self.assertRaises(Exception):
-        #     arnied_wrapper.go_online(1)
 
     def test_disable_virscan(self):
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[5:13]
+        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[6:14]
         arnied_wrapper.disable_virscan()
 
     def test_email_transfer(self):
-        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[13:14]
+        DummyCmdOutputMapping.asserted_cmds = self.cmd_db[14:15]
         arnied_wrapper.email_transfer()