コード例 #1
0
ファイル: test_cni_plugin.py プロジェクト: grkvlt/calico-cni
    def test_main_unhandled_exception(self, m_conf_log, m_plugin, m_sys, m_os):
        """Test main() unhandled Exception"""
        # Mock out _execute to throw SystemExit
        m_os.environ = self.env
        m_sys.stdin.readlines.return_value = json.dumps(self.network_config)
        m_plugin(self.env, self.network_config).execute.side_effect = Exception 
        m_plugin.reset_mock()

        # Call
        main()

        # Assert
        m_sys.exit.assert_called_once_with(ERR_CODE_GENERIC)
コード例 #2
0
ファイル: test_cni_plugin.py プロジェクト: grkvlt/calico-cni
    def test_main_sys_exit(self, m_conf_log, m_plugin, m_sys, m_os):
        """Test main() SystemExit handling"""
        # Mock out _execute to throw SystemExit
        m_os.environ = self.env
        m_sys.stdin.readlines.return_value = json.dumps(self.network_config)
        m_plugin(self.env, self.network_config).execute.side_effect = SystemExit(5)
        m_plugin.reset_mock()

        # Call
        main()

        # Assert
        m_sys.exit.assert_called_once_with(5)
コード例 #3
0
    def test_main_unhandled_exception(self, m_conf_log, m_plugin, m_sys, m_os):
        """Test main() unhandled Exception"""
        # Mock out _execute to throw SystemExit
        m_os.environ = self.env
        m_sys.stdin.readlines.return_value = json.dumps(self.network_config)
        m_plugin(self.env, self.network_config).execute.side_effect = Exception
        m_plugin.reset_mock()

        # Call
        main()

        # Assert
        m_sys.exit.assert_called_once_with(ERR_CODE_GENERIC)
コード例 #4
0
ファイル: test_cni_plugin.py プロジェクト: grkvlt/calico-cni
    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(self.env, self.network_config).execute.return_value = 0
        m_plugin.reset_mock()

        # Call
        main()

        # Assert
        m_plugin.assert_called_once_with(self.network_config, self.env)
        m_conf_log.assert_called_once_with(ANY, "cni.log", log_level="INFO")
        m_sys.exit.assert_called_once_with(0)
コード例 #5
0
    def test_main_sys_exit(self, m_conf_log, m_plugin, m_sys, m_os):
        """Test main() SystemExit handling"""
        # Mock out _execute to throw SystemExit
        m_os.environ = self.env
        m_sys.stdin.readlines.return_value = json.dumps(self.network_config)
        m_plugin(self.env,
                 self.network_config).execute.side_effect = SystemExit(5)
        m_plugin.reset_mock()

        # Call
        main()

        # Assert
        m_sys.exit.assert_called_once_with(5)
コード例 #6
0
    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(self.env, self.network_config).execute.return_value = 0
        m_plugin.reset_mock()

        # Call
        main()

        # Assert
        m_plugin.assert_called_once_with(self.network_config, self.env)
        m_conf_log.assert_called_with(ANY, "WARNING", "WARNING", "cni.log")
        m_sys.exit.assert_called_once_with(0)