Skip to content

Commit

Permalink
refac: Change default output path and -o now supports --types, `-…
Browse files Browse the repository at this point in the history
…-modules`, `-i` and `-il`. #2075
  • Loading branch information
Luis Gonzalez committed Nov 3, 2021
1 parent 2a08267 commit 2d973f1
Showing 1 changed file with 8 additions and 30 deletions.
38 changes: 8 additions & 30 deletions deps/wazuh_testing/wazuh_testing/scripts/qa_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import os
import sys
import json

from datetime import datetime
from elasticsearch import Elasticsearch
from tempfile import gettempdir

from wazuh_testing.qa_docs.lib.config import Config
from wazuh_testing.qa_docs.lib.index_data import IndexData
Expand All @@ -20,7 +22,7 @@

VERSION_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'qa_docs', 'VERSION.json')
SCHEMA_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'qa_docs', 'schema.yaml')
OUTPUT_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'qa_docs', 'output')
OUTPUT_PATH = os.path.join(gettempdir(), 'qa_docs', 'output')
LOG_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'qa_docs', 'log')
SEARCH_UI_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'qa_docs', 'search_ui')
qadocs_logger = Logging(QADOCS_LOGGER, 'INFO', True, os.path.join(LOG_PATH,
Expand Down Expand Up @@ -48,6 +50,10 @@ def set_parameters(args):
if args.no_logging:
set_qadocs_logger_level(None)

if args.output_path:
global OUTPUT_PATH
OUTPUT_PATH = args.output_path


def get_parameters():
"""Capture the script parameters
Expand Down Expand Up @@ -195,36 +201,14 @@ def check_incompatible_parameters(parameters):
qadocs_logger.error)

if parameters.output_path:
if parameters.test_types:
raise QAValueError('The -o option is not compatible with --types. The default output path is generated '
'within the qa-docs tool to index it and visualize it.',
qadocs_logger.error)

if parameters.test_modules:
raise QAValueError('The -o option is not compatible with --modules. The default output path is generated '
'within the qa-docs tool to index it and visualize it.',
qadocs_logger.error)

if parameters.index_name:
raise QAValueError('The -o option is not compatible with -i option',
qadocs_logger.error)

if parameters.app_index_name:
raise QAValueError('The -o option is not compatible with -l option',
qadocs_logger.error)

if parameters.launching_index_name:
raise QAValueError('The -o option is not compatible with -il option',
qadocs_logger.error)

if parameters.test_exist:
raise QAValueError('The -o option is not compatible with -e option',
qadocs_logger.error)

if not parameters.test_names:
raise QAValueError('The -o option needs a list of tests to parse. You can use -t or --tests.',
qadocs_logger.error)

if parameters.no_logging and parameters.debug_level:
raise QAValueError('You cannot specify debug level and no-logging at the same time.',
qadocs_logger.error)
Expand Down Expand Up @@ -310,13 +294,7 @@ def parse_data(args):
elif args.test_names:
qadocs_logger.info(f"Parsing the following test(s) {args.test_names}")

# When output path is specified by user, a json is generated within that path
if args.output_path:
docs = DocGenerator(Config(SCHEMA_PATH, args.tests_path, args.output_path, test_names=args.test_names,
check_doc=args.check_doc))
# When no output is specified, it is generated within the default qa-docs output folder
else:
docs = DocGenerator(Config(SCHEMA_PATH, args.tests_path, OUTPUT_PATH, test_names=args.test_names,
docs = DocGenerator(Config(SCHEMA_PATH, args.tests_path, OUTPUT_PATH, test_names=args.test_names,
check_doc=args.check_doc))

# Parse a list of test types
Expand Down

0 comments on commit 2d973f1

Please sign in to comment.