Ejemplo n.º 1
0
def test_positive_create_with_inherited_params(module_org, module_location):
    """Create a new Host in organization and location with parameters

    :BZ: 1287223

    :id: 5e17e968-7fe2-4e5b-90ca-ae66f4e5307a

    :customerscenario: true

    :expectedresults: Host has inherited parameters from organization and
        location as well as global parameters

    :CaseImportance: High
    """
    org_param = entities.Parameter(organization=module_org).create()
    loc_param = entities.Parameter(location=module_location).create()
    host = entities.Host(location=module_location, organization=module_org).create()
    # get global parameters
    glob_param_list = {(param.name, param.value) for param in entities.CommonParameter().search()}
    # if there are no global parameters, create one
    if len(glob_param_list) == 0:
        param_name = gen_string('alpha')
        param_global_value = gen_string('numeric')
        entities.CommonParameter(name=param_name, value=param_global_value).create()
        glob_param_list = {
            (param.name, param.value) for param in entities.CommonParameter().search()
        }
    assert len(host.all_parameters) == 2 + len(glob_param_list)
    innerited_params = {(org_param.name, org_param.value), (loc_param.name, loc_param.value)}
    expected_params = innerited_params.union(glob_param_list)
    assert expected_params == {(param['name'], param['value']) for param in host.all_parameters}
Ejemplo n.º 2
0
def module_global_params():
    """Create 3 global parameters and clean up at teardown"""
    global_parameters = []
    for _ in range(3):
        global_parameter = entities.CommonParameter(
            name=gen_string('alpha'),
            value=gen_string('alphanumeric')).create()
        global_parameters.append(global_parameter)
    yield global_parameters
    # cleanup global parameters
    for global_parameter in global_parameters:
        global_parameter.delete()
Ejemplo n.º 3
0
    def test_positive_delete(self):
        """Create Global Parameter with valid values then delete it.

        :id: 1406d572-9e30-44e8-8637-2abe573e8958

        :expectedresults: Global Parameter is deleted

        :CaseImportance: Critical
        """
        with Session(self):
            for name in global_parameters_valid_names_list():
                with self.subTest(name):
                    entities.CommonParameter(name=name).create()
                    self.globalparameters.delete(name)
Ejemplo n.º 4
0
def test_positive_search_by_parameter_with_operator(session, module_loc):
    """Search by global parameter assigned to host using operator '<>' and
    any random string as parameter value to make sure that all hosts will
    be present in the list

    :id: 264065b7-0d04-467d-887a-0aba0d871b7c

    :expectedresults: All assigned hosts to organization are returned by
        search

    :BZ: 1463806

    :CaseLevel: Integration
    """
    org = entities.Organization().create()
    param_name = gen_string('alpha')
    param_value = gen_string('alpha')
    param_global_value = gen_string('numeric')
    search_param_value = gen_string('alphanumeric')
    entities.CommonParameter(name=param_name,
                             value=param_global_value).create()
    parameters = [{'name': param_name, 'value': param_value}]
    param_host = entities.Host(
        organization=org,
        location=module_loc,
        host_parameters_attributes=parameters,
    ).create()
    additional_host = entities.Host(organization=org,
                                    location=module_loc).create()
    with session:
        session.organization.select(org_name=org.name)
        # Check that the hosts are present
        for host in [param_host, additional_host]:
            assert session.host.search(host.name)[0]['Name'] == host.name
        # Check that search by parameter with '<>' operator returns both hosts
        values = session.host.search('params.{0} <> {1}'.format(
            param_name, search_param_value))
        assert {value['Name']
                for value in values
                } == {param_host.name, additional_host.name}