Exemplo n.º 1
0
    def test_negative_list_with_non_existing_org_and_loc_by_name(self):
        """Test Environment List filtering parameters validation.

        :id: 38cb48e3-a836-47d0-b8a8-9acd33a30546

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        loc = make_location()
        make_environment({
            'organizations': org['name'],
            'locations': loc['name'],
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization': org['name'],
                'location': gen_string('alpha')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization': gen_string('alpha'),
                'location': loc['name']
            })
Exemplo n.º 2
0
    def test_negative_list_with_parameters(self):
        """Test Environment List filtering parameters validation.

        :id: 97872953-e1aa-44bd-9ce0-a04bccbc9e94

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        make_environment({
            'organization-ids': self.org.id,
            'location-ids': self.loc.id,
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': self.org.id,
                'location-id': gen_string('numeric')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': gen_string('numeric'),
                'location-id': self.loc.id
            })
        # Filter by another location
        results = Environment.list({
            'organization': self.org.name,
            'location': self.loc2.name
        })
        self.assertEqual(len(results), 0)
Exemplo n.º 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'])
     })
Exemplo n.º 4
0
    def test_negative_list_with_non_existing_org_and_loc_by_id(self):
        """Test Environment List filtering parameters validation.

        :id: 97872953-e1aa-44bd-9ce0-a04bccbc9e94

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        loc = make_location()
        make_environment({
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': org['id'],
                'location-id': gen_string('numeric')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': gen_string('numeric'),
                'location-id': loc['id']
            })
Exemplo n.º 5
0
    def test_delete(self):
        """@Test: Delete the environment

        @Feature: Environment - Delete

        @Assert: Environment Delete is displayed

        """

        name = gen_string("alphanumeric", 10)
        try:
            make_environment({'name': name})
        except CLIFactoryError as err:
            self.fail(err)

        result = Environment().delete({'name': name})
        self.assertEqual(result.return_code, 0, "Deletion failed")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here")

        result = Environment().info({'name': name})
        self.assertNotEqual(
            result.return_code, 0, "Environment should be deleted")
        self.assertGreater(len(result.stderr), 0,
                           "There should be an exception here")
Exemplo n.º 6
0
    def test_positive_list_with_org_and_loc_by_name(self):
        """Test Environment List filtering.

        :id: 962c6750-f203-4478-8827-651db208ff92

        :expectedresults: Results that match both organization and location are
            returned

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create 2 envs with the same organization but different locations
        org = make_org()
        locs = [make_location() for _ in range(2)]
        envs = [make_environment({
            'organizations': org['name'],
            'locations': loc['name'],
        }) for loc in locs]
        results = Environment.list({'organization': org['name']})
        # List environments for the whole organization
        self.assertEqual(len(results), 2)
        self.assertEqual(
            {env['name'] for env in envs},
            {result['name'] for result in results}
        )
        # List environments with additional location filtering
        results = Environment.list({
            'organization': org['name'],
            'location': locs[0]['name'],
        })
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['name'], envs[0]['name'])
Exemplo n.º 7
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'])
Exemplo n.º 8
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'])
Exemplo n.º 9
0
    def test_positive_list_with_org_and_loc_by_name(self):
        """Test Environment List filtering.

        :id: 962c6750-f203-4478-8827-651db208ff92

        :expectedresults: Results that match both organization and location are
            returned

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create 2 envs with the same organization but different locations
        org = make_org()
        locs = [make_location() for _ in range(2)]
        envs = [
            make_environment({
                'organizations': org['name'],
                'locations': loc['name'],
            }) for loc in locs
        ]
        results = Environment.list({'organization': org['name']})
        # List environments for the whole organization
        self.assertEqual(len(results), 2)
        self.assertEqual({env['name']
                          for env in envs},
                         {result['name']
                          for result in results})
        # List environments with additional location filtering
        results = Environment.list({
            'organization': org['name'],
            'location': locs[0]['name'],
        })
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['name'], envs[0]['name'])
Exemplo n.º 10
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'])
Exemplo n.º 11
0
    def test_positive_list_with_org_and_loc_by_id(self):
        """Test Environment List filtering.

        :id: 643f7cb5-0817-4b0a-ba5e-434df2033a40

        :expectedresults: Results that match both organization and location are
            returned

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create 2 envs with the same organization but different locations
        org = make_org()
        locs = [make_location() for _ in range(2)]
        envs = [
            make_environment({
                'organization-ids': org['id'],
                'location-ids': loc['id'],
            }) for loc in locs
        ]
        results = Environment.list({'organization-id': org['id']})
        # List environments for the whole organization
        self.assertEqual(len(results), 2)
        self.assertEqual({env['id']
                          for env in envs},
                         {result['id']
                          for result in results})
        # List environments with additional location filtering
        results = Environment.list({
            'organization-id': org['id'],
            'location-id': locs[0]['id'],
        })
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['id'], envs[0]['id'])
Exemplo n.º 12
0
    def test_negative_list_with_non_existing_org_and_loc_by_name(self):
        """Test Environment List filtering parameters validation.

        :id: 38cb48e3-a836-47d0-b8a8-9acd33a30546

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        loc = make_location()
        make_environment({
            'organizations': org['name'],
            'locations': loc['name'],
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization': org['name'],
                'location': gen_string('alpha')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization': gen_string('alpha'),
                'location': loc['name']
            })
Exemplo n.º 13
0
    def test_positive_list_with_org_and_loc_by_id(self):
        """Test Environment List filtering.

        :id: 643f7cb5-0817-4b0a-ba5e-434df2033a40

        :expectedresults: Results that match both organization and location are
            returned

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create 2 envs with the same organization but different locations
        org = make_org()
        locs = [make_location() for _ in range(2)]
        envs = [make_environment({
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        }) for loc in locs]
        results = Environment.list({'organization-id': org['id']})
        # List environments for the whole organization
        self.assertEqual(len(results), 2)
        self.assertEqual(
            {env['id'] for env in envs},
            {result['id'] for result in results}
        )
        # List environments with additional location filtering
        results = Environment.list({
            'organization-id': org['id'],
            'location-id': locs[0]['id'],
        })
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['id'], envs[0]['id'])
Exemplo n.º 14
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'])
Exemplo n.º 15
0
    def test_negative_list_with_non_existing_org_and_loc_by_id(self):
        """Test Environment List filtering parameters validation.

        :id: 97872953-e1aa-44bd-9ce0-a04bccbc9e94

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        loc = make_location()
        make_environment({
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': org['id'],
                'location-id': gen_string('numeric')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': gen_string('numeric'),
                'location-id': loc['id']
            })
Exemplo n.º 16
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'])
Exemplo n.º 17
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'])
Exemplo n.º 18
0
    def test_positive_sc_params_by_name(self):
        """Check if environment sc-param subcommand works passing
        an environment name

        @id: e2fdd262-9b09-4252-8a5a-4e578e3b8547

        @Assert: The command runs without raising an error

        """
        environment = make_environment()
        Environment.sc_params({'environment': environment['name']})
Exemplo n.º 19
0
    def test_positive_sc_params_by_id(self):
        """Check if environment sc-param subcommand works passing
        an environment id

        @id: 32de4f0e-7b52-411c-a111-9ed472c3fc34

        @Assert: The command runs without raising an error

        """
        environment = make_environment()
        Environment.sc_params({'environment-id': environment['id']})
Exemplo n.º 20
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @id: 48765173-6086-4b91-9da7-594135f68751

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 21
0
    def test_negative_delete_by_id(self):
        """Create Environment then delete it by wrong ID

        @id: fe77920c-62fd-4e0e-b960-a940a1370d10

        @assert: Environment is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.delete({'id': entity_id})
Exemplo n.º 22
0
    def test_negative_create_with_name(self):
        """Don't create an Environment with invalid data.

        @id: 8a4141b0-3bb9-47e5-baca-f9f027086d4c

        @Assert: Environment is not created.
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.create({'name': name})
Exemplo n.º 23
0
    def test_negative_delete_by_id(self):
        """Create Environment then delete it by wrong ID

        @id: fe77920c-62fd-4e0e-b960-a940a1370d10

        @assert: Environment is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.delete({'id': entity_id})
Exemplo n.º 24
0
    def test_negative_create_with_name(self):
        """Don't create an Environment with invalid data.

        @id: 8a4141b0-3bb9-47e5-baca-f9f027086d4c

        @Assert: Environment is not created.
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.create({'name': name})
Exemplo n.º 25
0
    def test_positive_sc_params_by_id(self):
        """Check if environment sc-param subcommand works passing
        an environment id

        @id: 32de4f0e-7b52-411c-a111-9ed472c3fc34

        @Assert: The command runs without raising an error

        """
        environment = make_environment()
        Environment.sc_params({'environment-id': environment['id']})
Exemplo n.º 26
0
    def test_positive_sc_params_by_name(self):
        """Check if environment sc-param subcommand works passing
        an environment name

        @Feature: Environment

        @Assert: The command runs without raising an error

        """
        environment = make_environment()
        Environment.sc_params({'environment': environment['name']})
Exemplo n.º 27
0
    def test_negative_delete_by_id(self):
        """Create Environment then delete it by wrong ID

        @feature: Environment

        @assert: Environment is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.delete({'id': entity_id})
Exemplo n.º 28
0
    def test_negative_delete_by_id(self):
        """Create Environment then delete it by wrong ID

        @feature: Environment

        @assert: Environment is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.delete({'id': entity_id})
Exemplo n.º 29
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @Feature: Environment

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 30
0
    def test_negative_create_with_name(self):
        """Don't create an Environment with invalid data.

        @Feature: Environment

        @Assert: Environment is not created.
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.create({'name': name})
Exemplo n.º 31
0
    def test_negative_create_with_name(self):
        """Don't create an Environment with invalid data.

        @Feature: Environment

        @Assert: Environment is not created.
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.create({'name': name})
Exemplo n.º 32
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @Feature: Environment

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 33
0
    def test_positive_sc_params_by_name(self):
        """Check if environment sc-param subcommand works passing
        an environment name

        @id: e2fdd262-9b09-4252-8a5a-4e578e3b8547

        @Assert: The command runs without raising an error

        """
        environment = make_environment()
        Environment.sc_params({'environment': environment['name']})
Exemplo n.º 34
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        @id: 48765173-6086-4b91-9da7-594135f68751

        @Assert: Environment is deleted.
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 35
0
 def test_list(self):
     """
     @Feature: Environment - List
     @Test: Test Environment List
     @Assert: Environment List is displayed
     """
     name = generate_string("alpha", 10)
     Environment().create({'name': name})
     result = Environment().list({'search': name})
     self.assertTrue(
         len(result.stdout) == 1,
         "Environment list - stdout contains 'Name'")
Exemplo n.º 36
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        :id: 48765173-6086-4b91-9da7-594135f68751

        :expectedresults: Environment is deleted.

        :CaseImportance: Critical
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 37
0
def test_negative_delete_by_id(entity_id):
    """Create Environment then delete it by wrong ID

    :id: fe77920c-62fd-4e0e-b960-a940a1370d10

    :parametrized: yes

    :expectedresults: Environment is not deleted

    :CaseImportance: Medium
    """
    with pytest.raises(CLIReturnCodeError):
        Environment.delete({'id': entity_id})
Exemplo n.º 38
0
def test_negative_create_with_name(name):
    """Don't create an Environment with invalid data.

    :id: 8a4141b0-3bb9-47e5-baca-f9f027086d4c

    :parametrized: yes

    :expectedresults: Environment is not created.

    :CaseImportance: Critical
    """
    with pytest.raises(CLIReturnCodeError):
        Environment.create({'name': name})
Exemplo n.º 39
0
    def test_positive_list_with_name(self):
        """Test Environment List

        @Feature: Environment

        @Assert: Environment list is displayed
        """
        for name in valid_environments_list():
            with self.subTest(name):
                Environment.create({'name': name})
                result = Environment.list({'search': 'name={0}'.format(name)})
                self.assertEqual(len(result), 1)
                self.assertEqual(result[0]['name'], name)
Exemplo n.º 40
0
    def test_negative_delete_by_id(self):
        """Create Environment then delete it by wrong ID

        :id: fe77920c-62fd-4e0e-b960-a940a1370d10

        :expectedresults: Environment is not deleted

        :CaseImportance: Critical
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.delete({'id': entity_id})
Exemplo n.º 41
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'])
Exemplo n.º 42
0
    def test_negative_create_with_name(self):
        """Don't create an Environment with invalid data.

        :id: 8a4141b0-3bb9-47e5-baca-f9f027086d4c

        :expectedresults: Environment is not created.

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.create({'name': name})
Exemplo n.º 43
0
    def test_negative_delete_by_id(self):
        """Create Environment then delete it by wrong ID

        :id: fe77920c-62fd-4e0e-b960-a940a1370d10

        :expectedresults: Environment is not deleted

        :CaseImportance: Medium
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.delete({'id': entity_id})
Exemplo n.º 44
0
    def test_positive_delete_by_name(self):
        """Delete the environment by its name.

        :id: 48765173-6086-4b91-9da7-594135f68751

        :expectedresults: Environment is deleted.

        :CaseImportance: Critical
        """
        environment = make_environment()
        Environment.delete({'name': environment['name']})
        with self.assertRaises(CLIReturnCodeError):
            Environment.info({'name': environment['name']})
Exemplo n.º 45
0
    def test_negative_create_with_name(self):
        """Don't create an Environment with invalid data.

        :id: 8a4141b0-3bb9-47e5-baca-f9f027086d4c

        :expectedresults: Environment is not created.

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    Environment.create({'name': name})
Exemplo n.º 46
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        @feature: Environment

        @assert: Environment is deleted
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 47
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        @feature: Environment

        @assert: Environment is deleted
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 48
0
    def test_info(self):
        """
        @Feature: Environment - Info
        @Test: Test Environment Info
        @Assert: Environment Info is displayed
        """
        name = generate_string("alpha", 10)
        Environment().create({'name': name})
        result = Environment().info({'name': name})

        self.assertTrue(result.return_code == 0, "Environment info - retcode")

        self.assertEquals(result.stdout['name'], name,
                          "Environment info - stdout contains 'Name'")
Exemplo n.º 49
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': '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']
     })
Exemplo n.º 50
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'])
Exemplo n.º 51
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']
Exemplo n.º 52
0
    def test_positive_list_with_name(self):
        """Test Environment List

        @Feature: Environment

        @Assert: Environment list is displayed
        """
        for name in valid_environments_list():
            with self.subTest(name):
                Environment.create({'name': name})
                result = Environment.list({
                    'search': 'name={0}'.format(name)
                })
                self.assertEqual(len(result), 1)
                self.assertEqual(result[0]['name'], name)
Exemplo n.º 53
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)
Exemplo n.º 54
0
    def test_negative_list_with_org_and_loc_by_id(self):
        """Test Environment List filtering.

        :id: b1659c48-302b-4fe3-a38b-cd34c0fd4878

        :expectedresults: Server returns empty result as there is no
            environment associated with location or organization

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        locs = [make_location() for _ in range(2)]
        make_environment({
            'organization-ids': org['id'],
            'location-ids': locs[0]['id'],
        })
        # But filter by another location
        results = Environment.list({
            'organization-id': org['id'],
            'location-id': locs[1]['id'],
        })
        self.assertEqual(len(results), 0)
Exemplo n.º 55
0
    def test_negative_list_with_org_and_loc_by_name(self):
        """Test Environment List filtering.

        :id: b8382ebb-ffa3-4637-b3b4-444af6c2fe9b

        :expectedresults: Server returns empty result as there is no
            environment associated with location or organization

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        locs = [make_location() for _ in range(2)]
        make_environment({
            'organizations': org['name'],
            'locations': locs[0]['name'],
        })
        # But filter by another location
        results = Environment.list({
            'organization': org['name'],
            'location': locs[1]['name'],
        })
        self.assertEqual(len(results), 0)
Exemplo n.º 56
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)
Exemplo n.º 57
0
    def test_positive_delete_by_id(self):
        """Create Environment with valid values then delete it
        by ID

        :id: e25af73a-d4ef-4287-83bf-625337d91392

        :expectedresults: Environment is deleted

        :CaseImportance: Critical
        """
        for name in valid_environments_list():
            with self.subTest(name):
                environment = make_environment({'name': name})
                Environment.delete({'id': environment['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Environment.info({'id': environment['id']})
Exemplo n.º 58
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()
     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]
     # 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'])
     })
Exemplo n.º 59
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': 'cli_test_classparameters'},
     ]
     cls.org = make_org()
     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]
     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]
Exemplo n.º 60
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)