def test_index_ordering():
    prior_os = ""
    prior_len = 0
    prior_cmd = ""
    used_os = []

    index = load_index_data()
    for row in index:
        template = row[0].strip()
        os_match = RE_TEMPLATE_OS.match(template)
        os = os_match.group(0)
        cmd = "_".join(template.split("_")[2:])
        cmd_len = len(cmd)
        check_val, check_msg = check_order(
            os, prior_os, cmd_len, prior_len, OS_CHOICES, used_os, cmd, prior_cmd
        )
        if not check_val:
            # assertFalse(check_val, msg=check_msg)
            print("Error on line: {0}".format(row))
            print("Error Message: {0}".format(check_msg))
        assert check_val
        if os not in used_os:
            used_os.append(os)
        prior_len = cmd_len
        prior_cmd = cmd
        prior_os = os
def extract_index_data():
    """Used to parametrize and report each test case with the necessary data."""
    index = sorted(load_index_data())
    mock_directories = []
    for row in index:
        # Trim template name to only parts making up platform and command directories
        template = row[0].strip()
        template_short = template.split(".textfsm")[0]
        # Get RegEx pattern to strip platform from template name
        platform = row[2].strip()
        # The platform attribute is a RegEx pattern,
        # so need to loop through each platform looking to find a match
        # in order to accurately derive platform name
        for directory in TEST_DIRECTORIES:
            if re.match(platform, directory):
                platform = directory
                break
        cut = len(platform) + 1
        command = template_short[cut:]
        mock_directories.append(f"tests/{platform}/{command}")
    return mock_directories
def test_index_ordering():

    os_choices = [
        'a10', 'alcatel_aos', 'alcatel_sros', 'arista_eos', 'aruba_os', 'avaya_ers', 'avaya_vsp',
        'brocade_fastiron', 'brocade_netiron', 'brocade_nos', 'brocade_vdx', 'brocade_vyos',
        'checkpoint_gaia', 'cisco_asa', 'cisco_ios', 'cisco_nxos', 'cisco_s300', 'cisco_wlc',
        'cisco_xe', 'cisco_xr', 'dell_force10', 'enterasys', 'extreme', 'f5_ltm', 'fortinet',
        'hp_comware', 'hp_procurve', 'huawei', 'juniper', 'juniper_junos', 'juniper_screenos',
        'alcatel_sros', 'linux', 'ovs_linux', 'paloalto_panos', 'quanta_mesh','ruckus_fastiron',
        'ubiquiti_edgeswitch', 'vmware_nsxv', 'vyatta_vyos', 'vyos', 'watchguard_firebox', 
        'siemens_ros',

    ]

    prior_os = ""
    prior_len = 0
    prior_cmd = ""
    used_os = []

    index = load_index_data()
    for row in index:
        template = row[0].strip()
        os = '_'.join(template.split('_')[:2])
        cmd = '_'.join(template.split('_')[2:])
        cmd_len = len(cmd)
        check_val, check_msg = check_order(
            os, prior_os, cmd_len, prior_len, os_choices, used_os, cmd, prior_cmd
        )
        if not check_val:
        #assertFalse(check_val, msg=check_msg)
            print("Error on line: {}".format(row))
            print("Error Message: {}".format(check_msg))
        assert check_val
        if os not in used_os:
            used_os.append(os)
        prior_len = cmd_len
        prior_cmd = cmd
        prior_os = os
def test_verify_parsed_and_reference_data_exists():
    """Verify that at least one test exists for all entries in the index file.

    TODO:
        Add test cases for ``KNOWN_MISSING_TESTS`` and remove related conditional.
        Remove "_ssh" from ``cisco_wlc_ssh`` and rely on vendor_platform_command syntax
            instead of using regex on the directories.
    """
    index = sorted(load_index_data())
    for row in index:
        template = row[0].strip()
        template_short = template.split('.')[0]
        platform = row[2].strip()
        for directory in os.listdir("tests"):
            if re.match(platform, directory):
                platform_directory = directory
                break
        cut = len(platform_directory) + 1
        command = template_short[cut:]
        if template_short not in KNOWN_MISSING_TESTS:
            cases = 'tests/%s/%s/*.raw' % (platform_directory, command)
            test_list = glob.glob(cases)
            assert len(test_list) != 0, 'Could not find tests for %s' % template
def test_verify_parsed_and_reference_data_exists():
    """Verify that at least one test exists for all entries in the index file.

    TODO:
        Add test cases for ``KNOWN_MISSING_TESTS`` and remove related conditional.
        Remove "_ssh" from ``cisco_wlc_ssh`` and rely on vendor_platform_command syntax
            instead of using regex on the directories.
    """
    index = sorted(load_index_data())
    for row in index:
        template = row[0].strip()
        template_short = template.split('.template')[0]
        platform = row[2].strip()
        for directory in os.listdir("tests"):
            if re.match(platform, directory):
                platform_directory = directory
                break
        cut = len(platform_directory) + 1
        command = template_short[cut:]
        if template_short not in KNOWN_MISSING_TESTS:
            cases = 'tests/%s/%s/*.raw' % (platform_directory, command)
            test_list = glob.glob(cases)
            assert len(test_list) != 0, 'Could not find tests for %s' % template
def test_index_ordering():

    os_choices = [
        'a10', 'alcatel_aos', 'alcatel_sros', 'arista_eos', 'aruba_os', 'avaya_ers', 'avaya_vsp',
        'brocade_fastiron', 'brocade_netiron', 'brocade_nos', 'brocade_vdx', 'brocade_vyos',
        'checkpoint_gaia', 'cisco_asa', 'cisco_ios', 'cisco_nxos', 'cisco_s300', 'cisco_wlc',
        'cisco_xe', 'cisco_xr', 'dell_force10', 'enterasys', 'extreme', 'f5_ltm', 'fortinet',
        'hp_comware', 'hp_procurve', 'huawei', 'juniper', 'juniper_junos', 'juniper_screenos',
        'alcatel_sros', 'linux', 'ovs_linux', 'paloalto_panos', 'quanta_mesh',
        'ubiquiti_edgeswitch', 'vmware_nsxv', 'vyatta_vyos', 'vyos',
    ]

    prior_os = ""
    prior_len = 0
    prior_cmd = ""
    used_os = []

    index = load_index_data()
    for row in index:
        template = row[0].strip()
        os = '_'.join(template.split('_')[:2])
        cmd = '_'.join(template.split('_')[2:])
        cmd_len = len(cmd)
        check_val, check_msg = check_order(
            os, prior_os, cmd_len, prior_len, os_choices, used_os, cmd, prior_cmd
        )
        if not check_val:
        #assertFalse(check_val, msg=check_msg)
            print("Error on line: {}".format(row))
            print("Error Message: {}".format(check_msg))
        assert check_val
        if os not in used_os:
            used_os.append(os)
        prior_len = cmd_len
        prior_cmd = cmd
        prior_os = os
Esempio n. 7
0
def test_index_ordering():

    os_choices = [
        "a10",
        "alcatel_aos",
        "alcatel_sros",
        "arista_eos",
        "aruba_os",
        "avaya_ers",
        "avaya_vsp",
        "brocade_fastiron",
        "brocade_netiron",
        "brocade_nos",
        "brocade_vdx",
        "brocade_vyos",
        "checkpoint_gaia",
        "ciena_6x",
        "cisco_asa",
        "cisco_ios",
        "cisco_nxos",
        "cisco_s300",
        "cisco_wlc",
        "cisco_xe",
        "cisco_xr",
        "dell_force10",
        "enterasys",
        "extreme",
        "extreme_os",
        "f5_ltm",
        "fortinet_fortios",
        "hp_comware",
        "hp_procurve",
        "huawei_vrp",
        "juniper",
        "juniper_junos",
        "juniper_screenos",
        "linux",
        "ovs_linux",
        "paloalto_panos",
        "quanta_mesh",
        "ruckus_fastiron",
        "ubiquiti_edgeswitch",
        "vmware_nsxv",
        "vyatta_vyos",
        "vyos",
        "watchguard_firebox",
    ]

    prior_os = ""
    prior_len = 0
    prior_cmd = ""
    used_os = []

    index = load_index_data()
    for row in index:
        template = row[0].strip()
        os = "_".join(template.split("_")[:2])
        cmd = "_".join(template.split("_")[2:])
        cmd_len = len(cmd)
        check_val, check_msg = check_order(os, prior_os, cmd_len, prior_len,
                                           os_choices, used_os, cmd, prior_cmd)
        if not check_val:
            # assertFalse(check_val, msg=check_msg)
            print("Error on line: {0}".format(row))
            print("Error Message: {0}".format(check_msg))
        assert check_val
        if os not in used_os:
            used_os.append(os)
        prior_len = cmd_len
        prior_cmd = cmd
        prior_os = os