From d6d4904f37c665cf3e8d666191a0b7fd0f59318f Mon Sep 17 00:00:00 2001 From: Samir Aguiar Date: Tue, 31 Aug 2021 22:23:04 -0300 Subject: [PATCH] Fix unit tests 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 | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff --git a/test/test_arnied_wrapper.py b/test/test_arnied_wrapper.py index 010fc30..ea41e82 100755 --- a/test/test_arnied_wrapper.py +++ b/test/test_arnied_wrapper.py @@ -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() -- 1.7.1