From 123bc058d4c9b7ec925c3ad27c71b4cf5ec96bc9 Mon Sep 17 00:00:00 2001 From: Amita Sharma Date: Wed, 23 Aug 2017 15:29:17 +0530 Subject: [PATCH] Issue 47840: Add docstrings to setup tests and use generage_ds_params Description: Refactor the setup test suite docstrings and use generage_ds_params Reviewed by: Simon Pichugin --- dirsrvtests/tests/suites/setup_ds/setup_ds_test.py | 109 ++++++++++----------- 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py b/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py index 21f19d9..76bb9c6 100644 --- a/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py +++ b/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py @@ -4,83 +4,82 @@ import pytest from lib389.utils import * -from lib389._constants import (DEFAULT_SUFFIX, LOCALHOST, SER_HOST, SER_PORT, - SER_SERVERID_PROP, SER_CREATION_SUFFIX, SER_INST_SCRIPTS_ENABLED, - PORT_STANDALONE, args_instance, ReplicaRole) +from lib389._constants import (DEFAULT_SUFFIX, SER_HOST, SER_PORT, + SER_SERVERID_PROP, SER_CREATION_SUFFIX, SER_INST_SCRIPTS_ENABLED, + args_instance, ReplicaRole) from lib389 import DirSrv DEBUGGING = os.getenv("DEBUGGING", default=False) if DEBUGGING: - logging.getLogger(__name__).setLevel(logging.DEBUG) + logging.getLogger(__name__).setLevel(logging.DEBUG) else: - logging.getLogger(__name__).setLevel(logging.INFO) + logging.getLogger(__name__).setLevel(logging.INFO) log = logging.getLogger(__name__) def create_instance(config_attr): - log.info('create_instance - Installs the instance and Sets the value of InstScriptsEnabled to true OR false.') - - log.info("Set up the instance and set the config_attr") - instance_data = generate_ds_params(1, ReplicaRole.STANDALONE) - # Create instance - standalone = DirSrv(verbose=False) - - # Args for the instance - args_instance[SER_HOST] = instance_data[SER_HOST] - args_instance[SER_PORT] = instance_data[SER_PORT] - args_instance[SER_SERVERID_PROP] = instance_data[SER_SERVERID_PROP] - args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX - args_instance[SER_INST_SCRIPTS_ENABLED] = config_attr - args_standalone = args_instance.copy() - standalone.allocate(args_standalone) - if standalone.exists(): - standalone.delete() - standalone.create() - standalone.open() - return standalone + log.info('create_instance - Installs the instance and Sets the value of InstScriptsEnabled to true OR false.') + + log.info("Set up the instance and set the config_attr") + instance_data = generate_ds_params(1, ReplicaRole.STANDALONE) + # Create instance + standalone = DirSrv(verbose=False) + + # Args for the instance + args_instance[SER_HOST] = instance_data[SER_HOST] + args_instance[SER_PORT] = instance_data[SER_PORT] + args_instance[SER_SERVERID_PROP] = instance_data[SER_SERVERID_PROP] + args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX + args_instance[SER_INST_SCRIPTS_ENABLED] = config_attr + args_standalone = args_instance.copy() + standalone.allocate(args_standalone) + if standalone.exists(): + standalone.delete() + standalone.create() + standalone.open() + return standalone @pytest.mark.parametrize("config_attr", ('true', 'false')) def test_slapd_InstScriptsEnabled(config_attr): - """Tests InstScriptsEnabled attribute with "True" and "False" options + """Tests InstScriptsEnabled attribute with "True" and "False" options - :id: 02faac7f-c44d-4a3e-bf2d-1021e51da1ed + :id: 02faac7f-c44d-4a3e-bf2d-1021e51da1ed - :setup: Standalone instance with slapd.InstScriptsEnabled option as "True" and "False" + :setup: Standalone instance with slapd.InstScriptsEnabled option as "True" and "False" - :steps: - 1. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "True". - 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. - 3. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "False". - 4. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. + :steps: + 1. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "True". + 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. + 3. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "False". + 4. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. - :expectedresults: - 1. Instance should be created. - 2. /usr/lib64/dirsrv/slapd-instance instance script directory should be created. - 3. Instance should be created. - 4. /usr/lib64/dirsrv/slapd-instance instance script directory should not be created. - """ + :expectedresults: + 1. Instance should be created. + 2. /usr/lib64/dirsrv/slapd-instance instance script directory should be created. + 3. Instance should be created. + 4. /usr/lib64/dirsrv/slapd-instance instance script directory should not be created. + """ - log.info('set SER_INST_SCRIPTS_ENABLED to {}'.format(config_attr)) - standalone = create_instance(config_attr) + log.info('set SER_INST_SCRIPTS_ENABLED to {}'.format(config_attr)) + standalone = create_instance(config_attr) - # Checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true and false - if config_attr == 'true': - log.info('checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true') - assert os.listdir('/usr/lib64/dirsrv/slapd-standalone') + # Checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true and false + if config_attr == 'true': + log.info('checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true') + assert os.listdir('/usr/lib64/dirsrv/slapd-standalone1') - elif config_attr == 'false': - log.info('checking instance script directory does not present when SER_INST_SCRIPTS_ENABLED is set to false') - assert not os.path.exists("/usr/lib64/dirsrv/slapd-standalone") + elif config_attr == 'false': + log.info('checking instance script directory does not present when SER_INST_SCRIPTS_ENABLED is set to false') + assert not os.path.exists("/usr/lib64/dirsrv/slapd-standalone1") - # Remove instance - standalone.delete() + # Remove instance + standalone.delete() if __name__ == '__main__': - # Run isolated - # -s for DEBUG mode - CURRENT_FILE = os.path.realpath(__file__) - pytest.main("-s %s" % CURRENT_FILE) - + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE) -- 2.9.4