Esempio n. 1
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.all_providers(metafunc)
    testgen.parametrize(metafunc,
                        argnames,
                        argvalues,
                        ids=idlist,
                        scope="module")
Esempio n. 2
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.all_providers(
        metafunc, required_fields=['provisioning'])
    testgen.parametrize(metafunc,
                        argnames,
                        argvalues,
                        ids=idlist,
                        scope="module")
Esempio n. 3
0
def pytest_generate_tests(metafunc):
    # Filter out providers without templates defined
    argnames, argvalues, idlist = testgen.all_providers(metafunc)
    # if metafunc.function is not test_ssa_template:
    argnames.append('analysis_type')

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        # if metafunc.function is test_ssa_template:
        #    new_idlist.append(args['provider'].key)
        #    new_argvalues.append([args["provider"]])
        #    continue

        vms = []
        provisioning_data = []

        try:
            vma_data = args['provider'].data.get('vm_analysis_new', {})
            vms = vma_data.get("vms", {})
            provisioning_data = vma_data.get("provisioning", {})
        except AttributeError:
            # Provider has no provisioning and/or vms list set
            continue

        for vm_analysis_key in vms:
            # Each VM can redefine a provisioning data
            vm_analysis_data = provisioning_data.copy()
            vm_analysis_data.update(vms[vm_analysis_key])

            if not {'image', 'fs-type'}.issubset(vm_analysis_data.viewkeys()):
                continue

            if vm_analysis_data['fs-type'] not in ['ntfs', 'fat32']:
                # Username and password are required for non-windows VMs
                if not {'username', 'password'}.issubset(
                        vm_analysis_data.viewkeys()):
                    continue

            # Set VM name here
            new_idlist.append('{}-{}'.format(idlist[i], vm_analysis_key))
            new_argvalues.append([args["provider"], vm_analysis_key])
    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without templates defined
    argnames, argvalues, idlist = testgen.all_providers(metafunc)
    # if metafunc.function is not test_ssa_template:
    argnames.append('analysis_type')

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        # if metafunc.function is test_ssa_template:
        #    new_idlist.append(args['provider'].key)
        #    new_argvalues.append([args["provider"]])
        #    continue

        vms = []
        provisioning_data = []

        try:
            vma_data = args['provider'].data.get('vm_analysis_new', {})
            vms = vma_data.get("vms", {})
            provisioning_data = vma_data.get("provisioning", {})
        except AttributeError:
            # Provider has no provisioning and/or vms list set
            continue

        for vm_analysis_key in vms:
            # Each VM can redefine a provisioning data
            vm_analysis_data = provisioning_data.copy()
            vm_analysis_data.update(vms[vm_analysis_key])

            if not {'image', 'fs-type'}.issubset(
                    vm_analysis_data.viewkeys()):
                continue

            if vm_analysis_data['fs-type'] not in ['ntfs', 'fat32']:
                # Username and password are required for non-windows VMs
                if not {'username', 'password'}.issubset(
                        vm_analysis_data.viewkeys()):
                    continue

            # Set VM name here
            new_idlist.append('{}-{}'.format(idlist[i], vm_analysis_key))
            new_argvalues.append([args["provider"], vm_analysis_key])
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Esempio n. 5
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.all_providers(metafunc)

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if metafunc.function in {test_vm_genealogy_detected} \
                and args["provider"].one_of(SCVMMProvider, RHEVMProvider):
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.all_providers(metafunc)
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")