Exemplo n.º 1
0
    def test__cannot_connect(self, module_patch, import_patch):
        mock_module = setup_module(module_patch)
        self.setup_session_root(import_patch)
        self.mock_session.start.side_effect = Exception("cannot connect")

        main()

        import_patch.assert_called_once_with("vspk.v5_0")
        mock_module.fail_json.assert_called_once_with(
            msg="Could not establish connection to VSD cannot connect")
Exemplo n.º 2
0
    def test__cannot_import(self, module_patch, import_patch):
        mock_module = setup_module(module_patch)
        import_patch.side_effect = ImportError("cannot import")

        main()

        import_patch.assert_called_once_with("vspk.v5_0")
        mock_module.fail_json.assert_called_once_with(
            msg='vspk is required for this module, or '
            'API version specified does not exist.')
Exemplo n.º 3
0
    def test__exception(self, module_patch, import_patch):
        mock_module = setup_module(module_patch)
        mock_root = self.setup_session_root(import_patch)
        mock_sys_config = self.setup_system_configs(mock_root)

        mock_sys_config.save.side_effect = Exception("cannot save")

        main()

        import_patch.assert_called_once_with("vspk.v5_0")
        mock_module.fail_json.assert_called_once_with(
            msg="Could not set event log age : cannot save")
Exemplo n.º 4
0
    def test__bambou_error(self, module_patch, import_patch):
        mock_module = setup_module(module_patch)
        mock_root = self.setup_session_root(import_patch)
        mock_sys_config = self.setup_system_configs(mock_root)

        mock_sys_config.save.side_effect = self.get_mock_bambou_error(
            400, "save error")

        main()

        import_patch.assert_called_once_with("vspk.v5_0")
        mock_module.fail_json.assert_called_once_with(
            msg="Could not set event log age : "
            "[HTTP 400(save error)] save error")
Exemplo n.º 5
0
    def test__success(self, module_patch, import_patch):
        mock_module = setup_module(module_patch)
        mock_root = self.setup_session_root(import_patch)
        mock_sys_config = self.setup_system_configs(mock_root)

        main()

        self.validate_session(import_patch)
        assert mock_sys_config.event_log_entry_max_age == TEST_PARAMS[
            "event_log_age"]
        mock_sys_config.save.assert_called_once_with()
        mock_module.fail_json.assert_not_called()
        mock_module.exit_json.assert_called_once_with(
            changed=True,
            result="Event log age set to %s" % TEST_PARAMS["event_log_age"])