示例#1
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        :id: 2c40caf9-95a0-4b87-bd97-0a4448746052

        :expectedresults: Environment Update finished and new organization is
            assigned


        :CaseImportance: Critical
        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
示例#2
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        :id: 2c40caf9-95a0-4b87-bd97-0a4448746052

        :expectedresults: Environment Update finished and new organization is
            assigned


        :CaseImportance: Critical
        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
示例#3
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': 'cli_test_variables'
         },
     ]
     cls.org = make_org()
     cls.loc = make_location()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': u'content_view="{0}"'.format(cv['name'])})[0]
     Environment.update({
         'name': cls.env['name'],
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
     })
     # Find imported puppet class
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     # And all its subclasses
     cls.puppet_subclasses = Puppet.list({
         'search':
         "name ~ {0}:: and environment = {1}".format(
             cls.puppet_class['name'], cls.env['name'])
     })
示例#4
0
def test_positive_CRUD_with_attributes(module_org, module_locs):
    """Check if Environment with attributes can be created, updated and removed

    :id: d2187971-86b2-40c9-a93c-66f37691ae2b

    :BZ: 1337947

    :expectedresults:
        1. Environment is created and has parameters assigned
        2. Environment can be listed by parameters
        3. Environment can be updated
        4. Environment can be removed

    :CaseImportance: Critical
    """
    # Create with attributes
    env_name = gen_string('alpha')
    environment = make_environment(
        {'location-ids': module_locs[0].id, 'organization-ids': module_org.id, 'name': env_name}
    )
    assert module_locs[0].name in environment['locations']
    assert module_org.name in environment['organizations']
    assert env_name == environment['name']

    # List by name
    result = Environment.list({'search': f'name={env_name}'})
    assert len(result) == 1
    assert result[0]['name'] == env_name
    # List by org loc id
    results = Environment.list({'organization-id': module_org.id, 'location-id': module_locs[0].id})
    assert env_name in [res['name'] for res in results]
    # List by org loc name
    results = Environment.list({'organization': module_org.name, 'location': module_locs[0].name})
    assert env_name in [res['name'] for res in results]

    # Update org and loc
    new_org = entities.Organization().create()
    Environment.update(
        {
            'location-ids': module_locs[1].id,
            'organization-ids': new_org.id,
            'name': environment['name'],
        }
    )
    env_info = Environment.info({'name': environment['name']})
    assert module_locs[1].name in env_info['locations']
    assert module_locs[0].name not in env_info['locations']
    assert new_org.name in env_info['organizations']
    assert module_org.name not in env_info['organizations']
    # Update name
    new_env_name = gen_string('alpha')
    Environment.update({'id': environment['id'], 'new-name': new_env_name})
    env_info = Environment.info({'id': environment['id']})
    assert env_info['name'] == new_env_name

    # Delete
    Environment.delete({'id': environment['id']})
    with pytest.raises(CLIReturnCodeError):
        Environment.info({'id': environment['id']})
示例#5
0
def module_puppet(default_sat, module_org, module_location):
    puppet_class = 'cli_test_classparameters'
    env_name = default_sat.create_custom_environment(repo=puppet_class)
    Environment.update({
        'name': env_name,
        'organization-ids': module_org.id,
        'location-ids': module_location.id,
    })
    puppet_class = Puppet.info({'name': puppet_class, 'environment': env_name})
    env = entities.Environment().search(
        query={'search': f'name="{env_name}"'})[0].read()
    yield {'env': env, 'class': puppet_class}
    delete_puppet_class(puppet_class['name'])
示例#6
0
def module_puppet(module_org, module_location):
    puppet_modules = [{'author': 'robottelo', 'name': 'cli_test_classparameters'}]
    cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO, module_org.id)
    env = Environment.list({'search': f'content_view="{cv["name"]}"'})[0]
    Environment.update(
        {
            'name': env['name'],
            'organization-ids': module_org.id,
            'location-ids': module_location.id,
        }
    )
    puppet_class = Puppet.info({'name': puppet_modules[0]['name'], 'environment': env['name']})
    yield {'modules': puppet_modules, 'env': env, 'class': puppet_class}
    delete_puppet_class(puppet_class['name'])
 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': 'cli_test_classparameters'
         },
     ]
     cls.org = make_org()
     cls.loc = make_location()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': u'content_view="{0}"'.format(cv['name'])})[0]
     Environment.update({
         'name': cls.env['name'],
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
     })
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     cls.sc_params_list = SmartClassParameter.list({
         'environment':
         cls.env['name'],
         'search':
         u'puppetclass="{0}"'.format(cls.puppet_class['name'])
     })
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in cls.sc_params_list
     ]
     cls.host = entities.Host(
         organization=cls.org['id'],
         location=cls.loc['id'],
         environment=cls.env['name'],
     ).create()
     cls.host.add_puppetclass(
         data={'puppetclass_id': cls.puppet_class['id']})
     cls.hostgroup = make_hostgroup({
         'environment-id':
         cls.env['id'],
         'puppet-class-ids':
         cls.puppet_class['id']
     })
示例#8
0
def test_negative_update_name(new_name):
    """Update the Environment with invalid values

    :id: adc5ad73-0547-40f9-b4d4-649780cfb87a

    :parametrized: yes

    :expectedresults: Environment is not updated

    """
    environment = make_environment()
    with pytest.raises(CLIReturnCodeError):
        Environment.update({'id': environment['id'], 'new-name': new_name})
    result = Environment.info({'id': environment['id']})
    assert environment['name'] == result['name']
示例#9
0
    def test_update_organization(self):
        """@Test: Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        try:
            old_org = make_org()
            new_org = make_org()
            env_name = gen_string('alphanumeric', 10)
            make_environment({
                'name': env_name,
                'organization-ids': old_org['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)
        result = Environment.info({'name': env_name})
        self.assertIn(old_org['name'], result.stdout['organizations'])

        result = Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        self.assertEqual(result.return_code, 0)

        result = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], result.stdout['organizations'])
        self.assertNotIn(old_org['name'], result.stdout['organizations'])
示例#10
0
    def test_update_negative(self, test_data):
        """@Test: Update the environment with invalid values

        @Feature: Environment - Update

        @Assert: Environment is not updated

        """
        orig_dict, updates_dict = test_data
        try:
            env = make_environment({'name': orig_dict['name']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment.update({
            'name': orig_dict['name'],
            'new-name': updates_dict['new-name']
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        result = Environment.info({'id': env['id']})
        # Verify that value is not updated and left as it was before update
        # command was executed
        self.assertEqual(result.stdout['name'], orig_dict['name'])
        self.assertNotEqual(result.stdout['name'], updates_dict['new-name'])
示例#11
0
    def test_update(self, test_data):
        """@Test: Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed

        """
        orig_dict, updates_dict = test_data
        try:
            make_environment({'name': orig_dict['name']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment.update({
            'name': orig_dict['name'],
            'new-name': updates_dict['new-name']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Environment.info({'name': updates_dict['new-name']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(result.stdout['name'], updates_dict['new-name'])
示例#12
0
    def test_positive_update_name(self):
        """Update the environment

        @id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
示例#13
0
    def test_update(self, test_data):
        """@Test: Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed

        """
        orig_dict, updates_dict = test_data
        try:
            make_environment({'name': orig_dict['name']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment.update({
            'name': orig_dict['name'],
            'new-name': updates_dict['new-name']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Environment.info({'name': updates_dict['new-name']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(result.stdout['name'], updates_dict['new-name'])
示例#14
0
    def test_update(self, new_name):
        """@Test: Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed

        """
        name = gen_string('alphanumeric')
        make_environment({'name': name})
        Environment.update({
            'name': name,
            'new-name': new_name,
        })
        env = Environment.info({'name': new_name})
        self.assertEqual(env['name'], new_name)
    def test_positive_update_name(self):
        """Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
示例#16
0
    def test_positive_update_name(self):
        """Update the environment

        @id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
示例#17
0
    def test_positive_update_name(self):
        """Update the environment

        @Feature: Environment - Update

        @Assert: Environment Update is displayed
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        @Feature: Environment

        @Assert: Environment is not updated
        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
示例#19
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        @Feature: Environment

        @Assert: Environment is not updated
        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
示例#20
0
    def test_positive_update_name(self):
        """Update the environment

        :id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        :expectedresults: Environment Update is displayed

        :CaseImportance: Critical
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
示例#21
0
    def test_positive_update_name(self):
        """Update the environment

        :id: 7b34ce64-24be-4b3b-8f7e-1de07daafdd9

        :expectedresults: Environment Update is displayed

        :CaseImportance: Critical
        """
        environment = make_environment()
        for new_name in valid_environments_list():
            with self.subTest(new_name):
                Environment.update({
                    'id': environment['id'],
                    'new-name': new_name,
                })
                environment = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], new_name)
示例#22
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        :id: adc5ad73-0547-40f9-b4d4-649780cfb87a

        :expectedresults: Environment is not updated

        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
示例#23
0
    def test_negative_update_name(self):
        """Update the Environment with invalid values

        :id: adc5ad73-0547-40f9-b4d4-649780cfb87a

        :expectedresults: Environment is not updated

        :CaseImportance: Critical
        """
        environment = make_environment()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.update({
                        'id': environment['id'],
                        'new-name': new_name,
                    })
                result = Environment.info({'id': environment['id']})
                self.assertEqual(environment['name'], result['name'])
示例#24
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @id: d58d6dc5-a820-4c61-bd69-0c631c2d3f2e

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
示例#25
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @id: d58d6dc5-a820-4c61-bd69-0c631c2d3f2e

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
示例#26
0
    def test_positive_update_loc(self):
        """Update environment location with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
    def test_positive_update_loc(self):
        """Update environment location with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new location is assigned

        """
        old_loc = make_location()
        new_loc = make_location()
        new_env = make_environment({'location-ids': old_loc['id']})
        self.assertIn(old_loc['name'], new_env['locations'])
        Environment.update({
            'location-ids': new_loc['id'],
            'name': new_env['name'],
        })
        new_env = Environment.info({'name': new_env['name']})
        self.assertIn(new_loc['name'], new_env['locations'])
        self.assertNotIn(old_loc['name'], new_env['locations'])
示例#28
0
    def test_update_negative(self, new_name):
        """@Test: Update the environment with invalid values

        @Feature: Environment - Update

        @Assert: Environment is not updated

        """
        name = gen_string('alphanumeric')
        env = make_environment({'name': name})
        with self.assertRaises(CLIReturnCodeError):
            Environment.update({
                'name': name,
                'new-name': new_name,
            })
        env = Environment.info({'id': env['id']})
        # Verify that value is not updated and left as it was before update
        # command was executed
        self.assertEqual(env['name'], name)
        self.assertNotEqual(env['name'], new_name)
示例#29
0
    def test_positive_update_org(self):
        """Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
    def test_positive_update_org(self):
        """Update environment organization with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new organization is assigned

        """
        old_org = make_org()
        new_org = make_org()
        env_name = gen_string('alphanumeric', 10)
        env = make_environment({
            'name': env_name,
            'organization-ids': old_org['id'],
        })
        self.assertIn(old_org['name'], env['organizations'])
        Environment.update({
            'name': env_name,
            'organization-ids': new_org['id']
        })
        env = Environment.info({'name': env_name})
        self.assertIn(new_org['name'], env['organizations'])
        self.assertNotIn(old_org['name'], env['organizations'])
示例#31
0
    def test_positive_CRUD_with_attributes(self):
        """Check if Environment with attributes can be created, updated and removed

        :id: d2187971-86b2-40c9-a93c-66f37691ae2b

        :bz: 1337947

        :expectedresults:
            1. Environment is created and has parameters assigned
            2. Environment can be listed by parameters
            3. Environment can be updated
            4. Environment can be removed

        :CaseImportance: Critical
        """
        # Create with attributes
        env_name = gen_string('alpha')
        environment = make_environment({
            'location-ids': self.loc.id,
            'organization-ids': self.org.id,
            'name': env_name,
        })
        self.assertIn(self.loc.name, environment['locations'])
        self.assertIn(self.org.name, environment['organizations'])
        self.assertEqual(env_name, environment['name'])

        # List by name
        result = Environment.list({'search': 'name={0}'.format(env_name)})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], env_name)
        # List by org loc id
        results = Environment.list({
            'organization-id': self.org.id,
            'location-id': self.loc.id,
        })
        self.assertIn(env_name, [res['name'] for res in results])
        # List by org loc name
        results = Environment.list({
            'organization': self.org.name,
            'location': self.loc.name,
        })
        self.assertIn(env_name, [res['name'] for res in results])

        # Update org and loc
        new_org = entities.Organization().create()
        Environment.update({
            'location-ids': self.loc2.id,
            'organization-ids': new_org.id,
            'name': environment['name'],
        })
        env_info = Environment.info({'name': environment['name']})
        self.assertIn(self.loc2.name, env_info['locations'])
        self.assertNotIn(self.loc.name, env_info['locations'])
        self.assertIn(new_org.name, env_info['organizations'])
        self.assertNotIn(self.org.name, env_info['organizations'])
        # Update name
        new_env_name = gen_string('alpha')
        Environment.update({
            'id': environment['id'],
            'new-name': new_env_name,
        })
        env_info = Environment.info({'id': environment['id']})
        self.assertEqual(env_info['name'], new_env_name)

        # Delete
        Environment.delete({'id': environment['id']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'id': environment['id']})