def test_main_execute_unhandled_error(self, m_exit, m_conf_log, m_plugin, m_sys, m_os): # Mock m_os.environ = self.env m_sys.stdin.readlines.return_value = json.dumps(self.network_config) m_plugin.reset_mock() m_plugin(self.env).execute.side_effect = Exception # Call main() # Assert m_exit.assert_called_once_with(ERR_CODE_GENERIC, message=ANY, details=ANY)
def test_main_execute_cni_error(self, m_exit, m_conf_log, m_plugin, m_sys, m_os): # Mock m_os.environ = self.env m_sys.stdin.readlines.return_value = json.dumps(self.network_config) m_plugin.reset_mock() m_plugin(self.env).execute.side_effect = CniError(50, "Message", "Details") # Call main() # Assert m_exit.assert_called_once_with(50, "Message", "Details")
def test_main(self, m_conf_log, m_plugin, m_sys, m_os): # Mock m_os.environ = self.env m_sys.stdin.readlines.return_value = json.dumps(self.network_config) m_plugin.reset_mock() # Call main() # Assert m_plugin.assert_called_once_with(self.env) m_plugin(self.env).execute.assert_called_once_with()
def test_main_execute_unhandled_error(self, m_exit, m_conf_log, m_plugin, m_sys, m_os): # Mock m_os.environ = self.env m_sys.stdin.readlines.return_value = json.dumps(self.network_config) m_plugin.reset_mock() m_plugin(self.env, self.network_config["ipam"]).execute.side_effect = Exception # Call main() # Assert m_exit.assert_called_once_with(ERR_CODE_GENERIC, message=ANY, details=ANY)
def test_main_execute_cni_error(self, m_exit, m_conf_log, m_plugin, m_sys, m_os): # Mock m_os.environ = self.env m_sys.stdin.readlines.return_value = json.dumps(self.network_config) m_plugin.reset_mock() m_plugin(self.env, self.network_config["ipam"]).execute.side_effect = CniError(50, "Message", "Details") # Call main() # Assert m_exit.assert_called_once_with(50, "Message", "Details")
def test_main(self, m_conf_log, m_plugin, m_sys, m_os): # Mock m_os.environ = self.env m_sys.stdin.readlines.return_value = json.dumps(self.network_config) m_plugin.reset_mock() # Call main() # Assert m_plugin.assert_called_once_with(self.env, self.network_config["ipam"]) m_plugin(self.env, self.network_config["ipam"]).execute.assert_called_once_with()