コード例 #1
0
ファイル: test_environment.py プロジェクト: tstrych/robottelo
def test_positive_update_and_remove(module_org, module_location):
    """Update environment and assign it to a new organization
    and location. Delete environment afterwards.

    :id: 31e43faa-65ee-4757-ac3d-3825eba37ae5

    :expectedresults: Environment entity is updated and removed
        properly

    :CaseImportance: Critical

    :CaseLevel: Integration
    """
    env = entities.Environment().create()
    assert len(env.organization) == 0
    assert len(env.location) == 0
    env = entities.Environment(id=env.id,
                               organization=[module_org
                                             ]).update(['organization'])
    assert len(env.organization) == 1
    assert env.organization[0].id, module_org.id

    env = entities.Environment(id=env.id,
                               location=[module_location]).update(['location'])
    assert len(env.location) == 1
    assert env.location[0].id == module_location.id

    env.delete()
    with pytest.raises(HTTPError):
        env.read()
コード例 #2
0
def test_create_with_puppet_class(session, module_org, module_loc):
    """Create new host group with assigned puppet class to it

    :id: 166ca6a6-c0f7-4fa0-a3f2-b0d6980cf50d

    :expectedresults: Host group created and contains proper puppet class

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    pc_name = 'generic_1'
    cv = publish_puppet_module(
        [{'author': 'robottelo', 'name': pc_name}],
        CUSTOM_PUPPET_REPO,
        organization_id=module_org.id
    )
    env = entities.Environment().search(query={
        'search': u'content_view="{0}" and organization_id={1}'.format(
            cv.name, module_org.id)})[0].read()
    env = entities.Environment(id=env.id, location=[module_loc]).update(['location'])
    with session:
        # Create host group with puppet class
        session.hostgroup.create({
            'host_group.name': name,
            'host_group.puppet_environment': env.name,
            'puppet_classes.classes.assigned': [pc_name],
        })
        hostgroup_values = session.hostgroup.read(name, widget_names='puppet_classes')
        assert len(hostgroup_values['puppet_classes']['classes']['assigned']) == 1
        assert hostgroup_values[
            'puppet_classes']['classes']['assigned'][0] == pc_name
コード例 #3
0
    def test_positive_update_and_remove(self):
        """Update environment and assign it to a new organization
        and location. Delete environment afterwards.

        :id: 31e43faa-65ee-4757-ac3d-3825eba37ae5

        :expectedresults: Environment entity is updated and removed
            properly

        :CaseImportance: Critical

        :CaseLevel: Integration
        """
        env = entities.Environment().create()
        self.assertEqual(len(env.organization), 0)
        self.assertEqual(len(env.location), 0)
        env = entities.Environment(
            id=env.id, organization=[self.org]).update(['organization'])
        self.assertEqual(len(env.organization), 1)
        self.assertEqual(env.organization[0].id, self.org.id)

        env = entities.Environment(
            id=env.id, location=[self.loc]).update(['location'])
        self.assertEqual(len(env.location), 1)
        self.assertEqual(env.location[0].id, self.loc.id)

        env.delete()
        with self.assertRaises(HTTPError):
            env.read()
コード例 #4
0
ファイル: test_hostgroup.py プロジェクト: lpramuk/robottelo
def test_create_with_puppet_class(session, module_org, module_loc,
                                  default_sat):
    """Create new host group with assigned puppet class to it

    :id: 166ca6a6-c0f7-4fa0-a3f2-b0d6980cf50d

    :expectedresults: Host group created and contains proper puppet class
    """
    name = gen_string('alpha')
    pc_name = 'generic_1'
    env_name = default_sat.create_custom_environment(repo=pc_name)
    env = default_sat.api.Environment().search(
        query={'search': f'name={env_name}'})[0].read()
    env = entities.Environment(
        id=env.id,
        location=[module_loc],
        organization=[module_org],
    ).update(['location', 'organization'])
    env = entities.Environment(id=env.id,
                               location=[module_loc]).update(['location'])
    with session:
        # Create host group with puppet class
        session.hostgroup.create({
            'host_group.name': name,
            'host_group.puppet_environment': env.name,
            'puppet_classes.classes.assigned': [pc_name],
        })
        hostgroup_values = session.hostgroup.read(
            name, widget_names='puppet_classes')
        assert len(
            hostgroup_values['puppet_classes']['classes']['assigned']) == 1
        assert hostgroup_values['puppet_classes']['classes']['assigned'][
            0] == pc_name
コード例 #5
0
    def test_positive_update_env(self):
        """Update a hostgroup with a new environment

        :id: 24f3852d-a94a-4d85-ab7b-afe845832d94

        :expectedresults: A hostgroup is updated with expected environment

        :CaseLevel: Integration
        """
        env = entities.Environment(
            location=[self.loc],
            organization=[self.org],
        ).create()
        hostgroup = entities.HostGroup(
            environment=env,
            location=[self.loc],
            organization=[self.org],
        ).create()
        new_env = entities.Environment(
            location=[self.loc],
            organization=[self.org],
        ).create()
        hostgroup.environment = new_env
        hostgroup = hostgroup.update(['environment'])
        self.assertEqual(hostgroup.environment.read().name, new_env.name)
コード例 #6
0
def module_puppet_environment(module_org, module_location):
    environments = entities.Environment().search(query=dict(
        search='organization_id={0}'.format(module_org.id)))
    if len(environments) > 0:
        environment = environments[0].read()
        environment.location.append(module_location)
        environment = environment.update(['location'])
    else:
        environment = entities.Environment(organization=[module_org],
                                           location=[module_location
                                                     ]).create()
    puppetenv = entities.Environment(id=environment.id).read()
    return puppetenv
コード例 #7
0
    def test_positive_update_org(self):
        """Update environment and assign it to a new organization

        @Feature: Environment

        @Assert: Environment entity is updated properly
        """
        env = entities.Environment().create()
        org = entities.Organization().create()
        env = entities.Environment(
            id=env.id, organization=[org]).update(['organization'])
        self.assertEqual(len(env.organization), 1)
        self.assertEqual(env.organization[0].id, org.id)
コード例 #8
0
    def test_positive_update_loc(self):
        """Update environment and assign it to a new location

        @Feature: Environment

        @Assert: Environment entity is updated properly
        """
        env = entities.Environment().create()
        location = entities.Location().create()
        env = entities.Environment(
            id=env.id, location=[location]).update(['location'])
        self.assertEqual(len(env.location), 1)
        self.assertEqual(env.location[0].id, location.id)
コード例 #9
0
    def test_negative_update_name(self):
        """Create environment entity providing the initial name, then
        try to update its name to invalid one.

        @id: 9cd024ab-db3d-4b15-b6da-dd2089321df3

        @Assert: Environment entity is not updated
        """
        env = entities.Environment().create()
        for new_name in invalid_names_list():
            with self.subTest(new_name):
                with self.assertRaises(HTTPError):
                    entities.Environment(id=env.id,
                                         name=new_name).update(['name'])
コード例 #10
0
    def test_positive_update_name(self):
        """Create environment entity providing the initial name, then
        update its name to another valid name.

        @id: ef48e79a-6b6a-4811-b49b-09f2effdd18f

        @Assert: Environment entity is created and updated properly
        """
        env = entities.Environment().create()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                env = entities.Environment(id=env.id,
                                           name=new_name).update(['name'])
                self.assertEqual(env.name, new_name)
コード例 #11
0
    def test_positive_update_loc(self):
        """Update environment and assign it to a new location

        :id: da56b040-69e3-4d4f-8ab3-3bfe923eaffe

        :expectedresults: Environment entity is updated properly

        :CaseLevel: Integration
        """
        env = entities.Environment().create()
        location = entities.Location().create()
        env = entities.Environment(id=env.id,
                                   location=[location]).update(['location'])
        self.assertEqual(len(env.location), 1)
        self.assertEqual(env.location[0].id, location.id)
コード例 #12
0
    def test_positive_update_org(self):
        """Update environment and assign it to a new organization

        :id: 31e43faa-65ee-4757-ac3d-3825eba37ae5

        :expectedresults: Environment entity is updated properly

        :CaseLevel: Integration
        """
        env = entities.Environment().create()
        org = entities.Organization().create()
        env = entities.Environment(id=env.id,
                                   organization=[org]).update(['organization'])
        self.assertEqual(len(env.organization), 1)
        self.assertEqual(env.organization[0].id, org.id)
コード例 #13
0
 def setUpClass(cls):
     """Set up reusable entities for tests."""
     super().setUpClass()
     cls.subnet = entities.Subnet().create()
     cls.env = entities.Environment().create()
     cls.env2 = entities.Environment().create()
     cls.domain = entities.Domain().create()
     cls.domain2 = entities.Domain().create()
     cls.medium = make_medium()
     cls.host_group = entities.HostGroup().create()
     cls.host_group2 = entities.HostGroup().create()
     cls.host_group3 = entities.HostGroup().create()
     cls.comp_resource = entities.LibvirtComputeResource().create()
     cls.template = entities.ProvisioningTemplate().create()
     cls.user = entities.User().create()
コード例 #14
0
def puppet_env(module_org, import_puppet_classes):
    """Update puppet environment"""
    puppet_env = entities.Environment().search(
        query={'search': 'name=production'})[0].read()
    puppet_env.organization.append(module_org)
    puppet_env = puppet_env.update(['organization'])
    return puppet_env
コード例 #15
0
def test_create_with_config_group(session, module_org, module_loc):
    """Create new host group with assigned config group to it

    :id: 05a64d6b-113b-4652-86bf-19bc65b70131

    :expectedresults: Host group created and contains proper config group

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    environment = entities.Environment(organization=[module_org],
                                       location=[module_loc]).create()
    config_group = entities.ConfigGroup().create()
    with session:
        # Create host group with config group
        session.hostgroup.create({
            'host_group.name':
            name,
            'host_group.puppet_environment':
            environment.name,
            'puppet_classes.config_groups.assigned': [config_group.name],
        })
        hostgroup_values = session.hostgroup.read(
            name, widget_names='puppet_classes')
        assert len(hostgroup_values['puppet_classes']['config_groups']
                   ['assigned']) == 1
        assert hostgroup_values['puppet_classes']['config_groups']['assigned'][
            0] == config_group.name
コード例 #16
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {'author': 'robottelo', 'name': 'api_test_classparameters'},
     ]
     cls.org = entities.Organization().create()
     cv = publish_puppet_module(
         cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.org)
     cls.env = entities.Environment().search(
         query={'search': u'content_view="{0}"'.format(cv.name)}
     )[0].read()
     cls.puppet_class = entities.PuppetClass().search(query={
         'search': u'name = "{0}" and environment = "{1}"'.format(
             cls.puppet_modules[0]['name'], cls.env.name)
     })[0]
     cls.sc_params_list = entities.SmartClassParameters().search(
         query={
             'search': 'puppetclass="{0}"'.format(cls.puppet_class.name),
             'per_page': 1000
         })
コード例 #17
0
ファイル: test_organization.py プロジェクト: renzon/robottelo
    def test_positive_create_with_all_environment(self):
        """Create organization with environment. Check and uncheck
        'all environments' setting. Verify that environment is assigned to
        organization and vice versa organization is assigned to environment

        :id: 7637d83b-3b40-4951-bdda-cdf78aa141f3

        :customerscenario: true

        :expectedresults: Organization and environment entities assigned to
            each other

        :BZ: 1479736

        :CaseLevel: Integration
        """
        org_name = gen_string('alpha')
        env = entities.Environment().create()
        with Session(self):
            self.assertIsNotNone(
                self.org.create_with_entity(org_name, 'envs', env.name))
            for value in [True, False]:
                self.org.assign_value(locators['org.all_environments'], value)
                self.org.click(common_locators['submit'])
                self.environment.search_and_click(env.name)
                self.environment.click(tab_locators['tab_org'])
                self.assertIsNotNone(
                    self.environment.wait_until_element(
                        common_locators['entity_deselect'] % org_name))
                self.org.search_and_click(org_name)
                self.org.click(tab_locators['context.tab_env'])
                self.assertIsNotNone(
                    self.org.wait_until_element(
                        common_locators['entity_deselect'] % env.name))
コード例 #18
0
    def test_positive_remove_environment(self):
        """Remove environment by using location name & environment name

        @feature: Locations

        @assert: environment is removed from Location
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for env_name in valid_env_names():
                with self.subTest(env_name):
                    loc_name = gen_string('alpha')
                    env = entities.Environment(name=env_name).create()
                    self.assertEqual(env.name, env_name)
                    set_context(session, org=ANY_CONTEXT['org'])
                    make_loc(session, name=loc_name, envs=[env_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_env'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % env_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.location.update(loc_name, envs=[env_name])
                    self.location.search(loc_name).click()
                    session.nav.click(tab_locators['context.tab_env'])
                    element = session.nav.wait_until_element(
                        (strategy, value % env_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
コード例 #19
0
    def test_positive_remove_environment(self):
        """Remove environment by using org & environment name.

        @feature: Organizations dis-associate environment.

        @assert: environment is removed from Organization.
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for env_name in valid_env_names():
                with self.subTest(env_name):
                    org_name = gen_string('alpha')
                    # Create environment using nailgun
                    env = entities.Environment(name=env_name).create_json()
                    self.assertEqual(env['name'], env_name)
                    make_org(session, org_name=org_name, envs=[env_name])
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_env'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % env_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.org.update(org_name, envs=[env_name])
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_env'])
                    element = session.nav.wait_until_element(
                        (strategy, value % env_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
コード例 #20
0
 def setUpClass(cls):
     """Create hostgroup and environment to be used on
     TemplateCombination creation
     """
     super(TemplateCombinationTestCase, cls).setUpClass()
     cls.hostgroup = entities.HostGroup().create()
     cls.env = entities.Environment().create()
コード例 #21
0
    def test_positive_update_environment(self):
        """Add and Remove environment by using org & environment name.

        :id: 270de90d-062e-4893-89c9-f6d0665ab967

        :expectedresults: environment is added then removed from Organization.

        :CaseLevel: Integration
        """
        with Session(self.browser) as session:
            org_name = gen_string('alpha')
            make_org(session, org_name=org_name)
            for environment_name in valid_env_names():
                with self.subTest(environment_name):
                    # Create environment using nailgun
                    environment = entities.Environment(
                        name=environment_name).create()
                    self.assertEqual(environment.name, environment_name)
                    kwargs = {
                        'org_name': org_name,
                        'entity_type': 'envs',
                        'entity_name': environment_name
                    }
                    self.assertIsNotNone(self.org.add_entity(**kwargs))
                    self.assertIsNotNone(self.org.remove_entity(**kwargs))
コード例 #22
0
def puppet_env(content_view, module_org):
    return entities.Environment().search(
        query={
            'search':
            u'content_view="{0}" and organization_id={1}'.format(
                content_view.name, module_org.id)
        })[0]
コード例 #23
0
 def setupScenario(self):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test.
     """
     self.puppet_modules = [{
         'author': 'robottelo',
         'name': 'api_test_classparameters'
     }]
     self.org = entities.Organization().create()
     cv = publish_puppet_module(self.puppet_modules, CUSTOM_PUPPET_REPO,
                                self.org)
     self.env = (entities.Environment().search(
         query={'search': 'content_view="{0}"'.format(cv.name)})[0].read())
     self.puppet_class = entities.PuppetClass().search(
         query={
             'search':
             'name = "{0}" and environment = "{1}"'.format(
                 self.puppet_modules[0]['name'], self.env.name)
         })[0]
     self.sc_params_list = entities.SmartClassParameters().search(
         query={
             'search': 'puppetclass="{0}"'.format(self.puppet_class.name),
             'per_page': 1000
         })
     scenario_ents = {
         self.__class__.__name__: {
             'puppet_class': self.puppet_class.name
         }
     }
     create_dict(scenario_ents)
コード例 #24
0
    def setUpClass(cls):
        """Import some parametrized puppet classes. This is required to make
        sure that we have smart class parameter available.
        Read all available smart class parameters for imported puppet class to
        be able to work with unique entity for each specific test.
        """
        super(SmartClassParametersTestCase, cls).setUpClass()
        cls.pm_name = 'ui_test_classparameters'
        cls.puppet_modules = [
            {'author': 'robottelo', 'name': cls.pm_name},
        ]
        cv = publish_puppet_module(
            cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.session_org)
        cls.env = entities.Environment().search(
            query={'search': u'content_view="{0}"'.format(cv.name)}
        )[0].read()
        cls.puppet_class = entities.PuppetClass().search(query={
            'search': u'name = "{0}" and environment = "{1}"'.format(
                cls.puppet_modules[0]['name'], cls.env.name)
        })[0]
        cls.sc_params_list = entities.SmartClassParameters().search(
            query={
                'search': 'puppetclass="{0}"'.format(cls.puppet_class.name),
                'per_page': 1000
            })

        cls.host = entities.Host(organization=cls.session_org).create()
        cls.host.environment = cls.env
        cls.host.update(['environment'])
        cls.host.add_puppetclass(data={'puppetclass_id': cls.puppet_class.id})
        cls.domain_name = entities.Domain(id=cls.host.domain.id).read().name
コード例 #25
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have data to be able to perform interactions with smart
     class variables.
     """
     super(SmartVariablesTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {
             'author': 'robottelo',
             'name': 'api_test_variables'
         },
     ]
     cls.org = entities.Organization().create()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org)
     cls.env = entities.Environment().search(
         query={'search': u'content_view="{0}"'.format(cv.name)})[0]
     # Find imported puppet class
     cls.puppet_class = entities.PuppetClass().search(
         query={
             'search':
             u'name = "{0}" and environment = "{1}"'.format(
                 cls.puppet_modules[0]['name'], cls.env.name)
         })[0]
     # And all its subclasses
     cls.puppet_subclasses = entities.PuppetClass().search(
         query={
             'search':
             u'name ~ "{0}::" and environment = "{1}"'.format(
                 cls.puppet_modules[0]['name'], cls.env.name)
         })
コード例 #26
0
    def test_positive_update_env(self):
        """Update location with new environment

        @id: 900a2441-4897-4e44-b8e4-bf7a956292ac

        @Assert: Location updated successfully and has correct environment
        assigned

        @CaseLevel: Integration
        """
        location = entities.Location(
            environment=[entities.Environment().create()], ).create()
        env = entities.Environment().create()
        location.environment = [env]
        self.assertEqual(
            location.update(['environment']).environment[0].id, env.id)
コード例 #27
0
    def test_positive_update_env(self):
        """Update location with new environment

        @Assert: Location updated successfully and has correct environment
        assigned

        @Feature: Location - Update
        """
        location = entities.Location(
            environment=[entities.Environment().create()],
        ).create()
        env = entities.Environment().create()
        location.environment = [env]
        self.assertEqual(
            location.update(['environment']).environment[0].id,
            env.id
        )
コード例 #28
0
ファイル: test_host.py プロジェクト: vatsalparekh/robottelo
def test_positive_reset_puppet_env_from_cv(session, module_org, module_loc):
    """Content View puppet environment is inherited to host in create
    procedure and can be rolled back to its value at any moment using
    'Reset Puppet Environment to match selected Content View' button

    :id: f8f35bd9-9e7c-418f-837a-ccec21c05d59

    :customerscenario: true

    :expectedresults: Expected puppet environment is inherited to the field

    :BZ: 1336802

    :CaseLevel: Integration
    """
    puppet_env = gen_string('alpha')
    content_view = gen_string('alpha')
    entities.Environment(name=puppet_env,
                         organization=[module_org],
                         location=[module_loc]).create()
    entities.ContentView(name=content_view, organization=module_org).create()
    with session:
        session.contentview.update(content_view,
                                   {'details.force_puppet': True})
        session.contentview.publish(content_view)
        published_puppet_env = [
            env.name for env in entities.Environment().search(
                query=dict(search='organization_id={0}'.format(module_org.id),
                           per_page=1000)) if content_view in env.name
        ][0]
        values = session.host.helper.read_create_view(
            {
                'host.lce': ENVIRONMENT,
                'host.content_view': content_view
            }, ['host.puppet_environment'])
        assert values['host']['puppet_environment'] == published_puppet_env
        values = session.host.helper.read_create_view(
            {'host.puppet_environment': puppet_env},
            ['host.puppet_environment'])
        assert values['host']['puppet_environment'] == puppet_env
        # reset_puppet_environment
        values = session.host.helper.read_create_view(
            {'host.reset_puppet_environment': True},
            ['host.puppet_environment'])
        assert values['host']['puppet_environment'] == published_puppet_env
コード例 #29
0
ファイル: test_location.py プロジェクト: rdrazny/robottelo
 def make_entities(self):
     """Set up reusable entities for tests."""
     return dict(
         domain=entities.Domain().create(),
         subnet=entities.Subnet().create(),
         env=entities.Environment().create(),
         host_group=entities.HostGroup().create(),
         template=entities.ProvisioningTemplate().create(),
         test_cr=entities.LibvirtComputeResource().create(),
         new_user=entities.User().create(),
     )
コード例 #30
0
    def test_positive_create_with_env(self):
        """Create new location with assigned environment to it

        @Assert: Location created successfully and has correct and expected
        environment assigned to it

        @Feature: Location
        """
        env = entities.Environment().create()
        location = entities.Location(environment=[env]).create()
        self.assertEqual(location.environment[0].id, env.id)