def test_positive_list_by_name(self):
        """Check if host collection list can be filtered by name

        :id: 2d611a48-1e51-49b5-8f20-81b09f96c542

        :expectedresults: Only host-collection with specific name is listed

        :CaseLevel: Integration
        """
        host_col_name = gen_string('alpha')
        # Create two host collections within the same org
        host_col = make_host_collection({
            'name': host_col_name,
            'organization-id': self.organization['id'],
        })
        make_host_collection({'organization-id': self.organization['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by name
        result = HostCollection.list({
            'name': host_col_name,
            'organization-id': self.organization['id'],
        })
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
    def test_positive_list_by_host_id(self):
        """Check if host collection list can be filtered by associated host id

        :id: de272461-9804-4524-83c8-23e47abfc8e3

        :expectedresults: Only host-collection with specific host is listed

        :CaseLevel: Integration

        :BZ: 1379372
        """
        # Create two host collections within the same org but only one with
        # associated host that will be used for filtering
        host_col = make_host_collection({
            'organization-id': self.organization['id'],
        })
        make_host_collection({'organization-id': self.organization['id']})
        host = self._make_fake_host_helper()
        HostCollection.add_host({
            'host-ids': host['id'],
            'id': host_col['id'],
        })
        host_col = HostCollection.info({
            'id': host_col['id'],
        })
        self.assertEqual(host_col['total-hosts'], '1')
        # List all host collections within organization
        result = HostCollection.list({
            'organization-id': self.organization['id']})
        self.assertGreaterEqual(len(result), 2)
        # Filter list by associated host id
        result = HostCollection.list({'host-id': host['id']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
示例#3
0
    def test_positive_update_host_collection_with_default_org(self):
        """Test that host collection can be associated to Activation
        Keys with specified default organization setting in config

        :id: 01e830e9-91fd-4e45-9aaf-862e1fe134df

        :expectedresults: Host collection is successfully associated to
            Activation key

        :BZ: 1364876
        """
        Defaults.add({
            u'param-name': 'organization_id',
            u'param-value': self.org['id'],
        })
        try:
            activation_key = self._make_activation_key()
            host_col = make_host_collection()
            ActivationKey.add_host_collection({
                u'host-collection': host_col['name'],
                u'name': activation_key['name'],
            })
            activation_key = ActivationKey.info({
                u'id': activation_key['id'],
            })
            self.assertEqual(
                activation_key['host-collections'][0]['name'],
                host_col['name']
            )
        finally:
            Defaults.delete({u'param-name': 'organization_id'})
    def test_positive_remove_host_by_name(self):
        """Check if content host can be removed from host collection by name

        :id: 924d0137-3a9e-4ecd-9631-c21f7e9a8d5d

        :customerscenario: true

        :expectedresults: Host collection is created and content-host is
            removed

        :CaseLevel: Integration
        """
        new_host_col = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_system = self._make_fake_host_helper()
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        no_of_content_host = HostCollection.info({
            u'id': new_host_col['id'],
        })['total-hosts']
        HostCollection.remove_host({
            u'host-ids': new_system['id'],
            u'name': new_host_col['name'],
            u'organization': self.organization['name'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
    def test_positive_remove_host_by_id(self):
        """Check if content host can be removed from host collection by id

        :id: 61f4aab1-398b-4d3a-a4f4-f558ad8d2679

        :expectedresults: Host collection is created and content-host is
            removed

        :CaseLevel: Integration
        """
        new_host_col = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_system = self._make_fake_host_helper()
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        no_of_content_host = HostCollection.info({
            u'id': new_host_col['id'],
        })['total-hosts']
        HostCollection.remove_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
    def test_positive_list_hosts(self):
        """Check if content hosts added to host collection is listed

        :id: 3075cb97-8448-4358-8ffc-0d5cd0078ca3

        :expectedresults: Content-host added to host-collection is listed

        :CaseLevel: Integration
        """
        host_col_name = gen_string('alpha', 15)
        new_host_col = make_host_collection({
            'name': host_col_name,
            'organization-id': self.organization['id'],
        })
        new_system = self._make_fake_host_helper()
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
        result = HostCollection.hosts({
            u'name': host_col_name,
            u'organization-id': self.organization['id']
        })
        self.assertEqual(new_system['name'].lower(), result[0]['name'])
    def test_positive_add_host_by_name(self):
        """Check if content host can be added to host collection by name

        :id: fe468f76-4693-4509-b534-126fce187194

        :customerscenario: true

        :expectedresults: Host collection is created and content-host is added

        :CaseLevel: Integration
        """
        new_host_col = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_system = self._make_fake_host_helper()
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'hosts': new_system['name'],
            u'name': new_host_col['name'],
            u'organization': self.organization['name'],
        })
        result = HostCollection.info({
            u'name': new_host_col['name'],
            u'organization': self.organization['name'],
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
    def test_positive_create_with_unlimited_hosts(self):
        """Create Host Collection with different values of
        unlimited-hosts parameter

        @Feature: Host Collection - Unlimited Hosts

        @Assert: Host Collection is created and unlimited-hosts
        parameter is set

        @BZ: 1214675

        """
        for unlimited in (u'True', u'Yes', 1, u'False', u'No', 0):
            with self.subTest(unlimited):
                host_collection = make_host_collection({
                    u'organization-id': self.org['id'],
                    u'unlimited-hosts': unlimited,
                })
                result = HostCollection.info({
                    u'id': host_collection['id'],
                    u'organization-id': self.org['id'],
                })
                if unlimited in (u'True', u'Yes', 1):
                    self.assertEqual(
                        result['unlimited-hosts'], u'true')
                else:
                    self.assertEqual(
                        result['unlimited-hosts'], u'false')
示例#9
0
    def test_associate_host(self):
        """@Test: Test that host collection can be associated to Activation
        Keys

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate the host collection to Activation key

        @Assert: Hosts are successfully associated to Activation key

        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({
                    'name': host_col_name,
                })['name']
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col_name,
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(
                    activation_key['host-collection'], host_col_name)
示例#10
0
    def test_create_hc_with_unlimited_content_hosts(self, unlimited):
        """@Test: Create Host Collection with different values of
        unlimited-content-hosts parameter

        @Feature: Host Collection - Unlimited Content Hosts

        @Assert: Host Collection is created and unlimited-content-hosts
        parameter is set

        @BZ: 1214675

        """
        try:
            host_collection = make_host_collection({
                u'organization-id': self.org['id'],
                u'unlimited-content-hosts': unlimited,
            })
        except CLIFactoryError as err:
            self.fail(err)
        result = HostCollection.info({
            u'id': host_collection['id'],
            u'organization-id': self.org['id'],
        })
        if unlimited in (u'True', u'Yes', 1):
            self.assertEqual(
                result.stdout['unlimited-content-hosts'], u'true')
        else:
            self.assertEqual(
                result.stdout['unlimited-content-hosts'], u'false')
    def test_positive_copy_by_id(self):
        """Check if host collection can be cloned by id

        :id: fd7cea50-bc56-4938-a81d-4f7a60711814

        :customerscenario: true

        :expectedresults: Host collection is cloned successfully

        :BZ: 1328925

        :CaseLevel: Integration
        """
        host_collection = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_name = gen_string('numeric')
        new_host_collection = HostCollection.copy({
            u'id': host_collection['id'],
            u'new-name': new_name,
        })
        result = HostCollection.info({
            u'id': new_host_collection[0]['id'],
        })
        self.assertEqual(result['name'], new_name)
    def test_positive_copy_by_name(self):
        """Check if host collection can be cloned by name

        :id: ca9be8de-ea9a-4890-8890-a1809a85a4ff

        :customerscenario: true

        :expectedresults: Host collection is cloned successfully

        :BZ: 1328925

        :CaseLevel: Integration
        """
        host_collection = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_name = gen_string('numeric')
        new_host_collection = HostCollection.copy({
            u'name': host_collection['name'],
            u'new-name': new_name,
            u'organization-label': self.organization['label'],
        })
        result = HostCollection.info({
            u'id': new_host_collection[0]['id'],
        })
        self.assertEqual(result['name'], new_name)
    def test_positive_create_with_unlimited_hosts(self):
        """Create Host Collection with different values of
        unlimited-hosts parameter

        @id: d688fd4a-88eb-484e-9e90-854e0595edd0

        @Assert: Host Collection is created and unlimited-hosts
        parameter is set
        """
        for unlimited in ('True', 'Yes', 1, 'False', 'No', 0):
            with self.subTest(unlimited):
                host_collection = make_host_collection({
                    'max-hosts':
                        1 if unlimited in ('False', 'No', 0) else None,
                    'organization-id': self.org['id'],
                    'unlimited-hosts': unlimited,
                })
                result = HostCollection.info({
                    'id': host_collection['id'],
                    'organization-id': self.org['id'],
                })
                if unlimited in ('True', 'Yes', 1):
                    self.assertEqual(result['limit'], 'None')
                else:
                    self.assertEqual(result['limit'], '1')
    def test_positive_host_collection_host_pagination(self):
        """Check if pagination configured on per-page param defined in hammer
        host-collection hosts command overrides global configuration defined
        on /etc/hammer/cli_config.yml, which default is 20 per page

        :BZ: 1343583

        :id: bbe1108b-bfb2-4a03-94ef-8fd1b5a0ec82

        :expectedresults: Number of host per page follows per_page
            configuration restriction

        :CaseLevel: Integration
        """
        host_collection = make_host_collection({
            'organization-id': self.organization['id'],
        })
        host_ids = ','.join(
            self._make_fake_host_helper()['id'] for _ in range(2)
        )
        HostCollection.add_host({
            u'host-ids': host_ids,
            u'id': host_collection['id'],
        })
        for number in range(1, 3):
            listed_hosts = HostCollection.hosts({
                u'id': host_collection['id'],
                u'organization-id': self.organization['id'],
                u'per-page': number
            })
            self.assertEqual(len(listed_hosts), number)
示例#15
0
    def test_positive_remove_host_collection_by_id(self):
        """@Test: Test that hosts associated to Activation Keys can be removed
        using id of that host collection

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate host collection to Activation key
        4. Remove host collection associated to Activation key using id of that
           collection

        @Assert: Host collection successfully removed from activation key
        """
        activation_key = self._make_activation_key()
        new_host_col = make_host_collection({
            u'name': gen_string('alpha'),
            u'organization-id': self.org['id'],
        })
        ActivationKey.add_host_collection({
            u'host-collection-id': new_host_col['id'],
            u'name': activation_key['name'],
            u'organization': self.org['name'],
        })
        activation_key = ActivationKey.info({u'id': activation_key['id']})
        self.assertEqual(len(activation_key['host-collections']), 1)
        ActivationKey.remove_host_collection({
            u'host-collection-id': new_host_col['id'],
            u'name': activation_key['name'],
            u'organization': self.org['name'],
        })
        activation_key = ActivationKey.info({u'id': activation_key['id']})
        self.assertEqual(len(activation_key['host-collections']), 0)
    def test_positive_delete_by_name(self):
        """Check if host collection can be created and deleted by name

        :id: a841a9f8-4285-40e5-9670-3f379dfd9a1e

        :customerscenario: true

        :expectedresults: Host collection is created and then deleted

        :BZ: 1328925

        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                new_host_col = make_host_collection({
                    'name': name,
                    'organization-id': self.organization['id'],
                })
                HostCollection.delete({
                    'name': new_host_col['name'],
                    'organization-id': self.organization['id'],
                })
                with self.assertRaises(CLIReturnCodeError):
                    HostCollection.info({'id': new_host_col['id']})
示例#17
0
    def test_positive_update_host_collection(self):
        """Test that host collection can be associated to Activation
        Keys

        @Feature: Activation key - Host

        @BZ: 1110476

        @Assert: Hosts are successfully associated to Activation key
        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({"name": host_col_name})["name"]
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection(
                    {
                        u"host-collection": new_host_col_name,
                        u"name": activation_key["name"],
                        u"organization-id": self.org["id"],
                    }
                )
                activation_key = ActivationKey.info({u"id": activation_key["id"]})
                self.assertEqual(activation_key["host-collection"], host_col_name)
示例#18
0
    def _new_host_collection(self, options=None):
        """Make a host collection and asserts its success"""

        if options is None:
            options = {}

        if not options.get('organization-id', None):
            options['organization-id'] = self.org['id']

        group = make_host_collection(options)

        # Fetch it
        result = HostCollection.info(
            {
                'id': group['id']
            }
        )

        self.assertEqual(
            result.return_code,
            0,
            "Host collection was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Return the host collection dictionary
        return group
示例#19
0
    def test_positive_update_host_collection(self):
        """Test that host collections can be associated to Activation
        Keys

        :id: 2114132a-fede-4791-98e7-a463ad79f398

        :BZ: 1110476

        :expectedresults: Host collections are successfully associated to
            Activation key

        :CaseLevel: Integration
        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({
                    u'name': host_col_name,
                    u'organization-id': self.org['id'],
                })['name']
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col_name,
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col_name
                )
    def _new_host_collection(self, options=None):
        """Make a host collection and asserts its success"""
        if options is None:
            options = {}
        if not options.get('organization-id', None):
            options['organization-id'] = self.org['id']

        return make_host_collection(options)
    def test_negative_create_with_name(self):
        """Attempt to create host collection with invalid name of different
        types

        :id: 92a9eff0-693f-4ab8-b2c4-de08e5f709a7

        :expectedresults: Host collection is not created and error is raised

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIFactoryError):
                    make_host_collection({
                        'name': name,
                        'organization-id': self.organization['id'],
                    })
    def test_positive_list_by_org_id(self):
        """Check if host collection list can be filtered by organization id

        :id: afbe077a-0de1-432c-a0c4-082129aab92e

        :expectedresults: Only host-collection within specific org is listed

        :CaseLevel: Integration
        """
        # Create two host collections within different organizations
        new_org = make_org()
        make_host_collection({
            'organization-id': self.organization['id'],
        })
        host_col = make_host_collection({'organization-id': new_org['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by org id
        result = HostCollection.list({'organization-id': new_org['id']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
    def test_positive_list_by_org_name(self):
        """Check if host collection list can be filtered by organization name

        :id: 0102094f-f5af-4067-8a07-541ba9d94f61

        :expectedresults: Only host-collection within specific org is listed

        :CaseLevel: Integration
        """
        # Create two host collections within different organizations
        new_org = make_org()
        make_host_collection({
            'organization-id': self.organization['id'],
        })
        host_col = make_host_collection({'organization-id': new_org['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by org name
        result = HostCollection.list({'organization': new_org['name']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], host_col['name'])
    def test_positive_list_by_host_name(self):
        """Check if host collection list can be filtered by
        associated host name

        :id: 2a99e11f-50b8-48b4-8dce-e6ad8ff9c051

        :expectedresults: Only host-collection with specific host is listed

        :CaseLevel: Integration

        :BZ: 1379372
        """
        # Create two host collections within the same org but only one with
        # associated host that will be used for filtering
        host_col = make_host_collection({
            'organization-id': self.organization['id'],
        })
        make_host_collection({'organization-id': self.organization['id']})
        host = self._make_fake_host_helper()
        HostCollection.add_host({
            'hosts': host['name'],
            'name': host_col['name'],
            'organization': self.organization['name'],
        })
        host_col = HostCollection.info({
            'name': host_col['name'],
            'organization': self.organization['name']
        })
        self.assertEqual(host_col['total-hosts'], '1')
        # List all host collections within organization
        result = HostCollection.list({
            'organization': self.organization['name']})
        self.assertGreaterEqual(len(result), 2)
        # Filter list by associated host name
        result = HostCollection.list({
            'organization': self.organization['name'],
            'host': host['name']
        })
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], host_col['name'])
    def test_associate_host(self, test_data):
        """@Test: Test that hosts can be associated to Activation Keys

        @Feature: Activation key - Host

        @Steps:
        1. Create Activation key
        2. Create different hosts
        3. Associate the hosts to Activation key

        @Assert: Hosts are successfully associated to Activation key

        """

        try:
            activation_key = self._make_activation_key({
                u'organization-id': self.org['id'],
            })
            new_host_col = make_host_collection({
                'name': test_data['host-col']
            })
        except CLIFactoryError as err:
            self.fail(err)

        # Assert that name matches data passed
            self.assertEqual(
                new_host_col['name'],
                test_data['host-col'],
                "Names don't match"
            )

        result = ActivationKey.add_host_collection({
            u'name': activation_key['name'],
            u'host-collection': new_host_col['name'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(
            result.return_code, 0, 'Failed to add host-col activation key')
        self.assertEqual(
            len(result.stderr), 0, 'There should not be an error here')

        result = ActivationKey.info({
            u'id': activation_key['id'],
        })
        self.assertEqual(
            result.return_code, 0, 'Failed to get info for activation key')
        self.assertEqual(
            len(result.stderr), 0, 'There should not be an error here')
        self.assertEqual(
            result.stdout['host-collection'], test_data['host-col'],
            'Activation key host-collection added')
示例#26
0
    def test_positive_remove_host_collection_by_name(self):
        """Test that hosts associated to Activation Keys can be removed
        using name of that host collection

        :id: 1a559a82-db5f-48b0-beeb-2fa02aed7ef9

        :Steps:

            1. Create Activation key
            2. Create host collection
            3. Associate host collection to Activation key
            4. Remove the host collection associated to Activation key using
               name of that collection

        :expectedresults: Host collection successfully removed from activation
            key

        :CaseLevel: Integration
        """
        for host_col in valid_data_list():
            with self.subTest(host_col):
                activation_key = self._make_activation_key()
                new_host_col = make_host_collection({
                    u'name': host_col,
                    u'organization-id': self.org['id'],
                })
                # Assert that name matches data passed
                self.assertEqual(new_host_col['name'], host_col)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 1)
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col,
                )
                ActivationKey.remove_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 0)
示例#27
0
    def test_remove_host(self, test_data):
        """@Test: Test that hosts associated to Activation Keys can be removed

        @Feature: Activation key - Host

        @Steps:
        1. Create Activation key
        2. Create different hosts
        3. Associate the hosts to Activation key
        4. Remove the hosts associated to Activation key

        @Assert: Hosts successfully removed that
        are associated to Activation key

        """
        try:
            org = make_org()
            activation_key = self._make_activation_key({u"organization-id": org["id"]})
            new_host_col = make_host_collection({u"name": test_data["host-col"], u"organization-id": org["id"]})
        except CLIFactoryError as err:
            self.fail(err)

        # Assert that name matches data passed
        self.assertEqual(new_host_col["name"], test_data["host-col"], "Names don't match")

        result = ActivationKey.add_host_collection(
            {u"name": activation_key["name"], u"host-collection": new_host_col["name"], u"organization-id": org["id"]}
        )
        self.assertEqual(result.return_code, 0, "Failed to add host-col activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")

        result = ActivationKey.info({u"id": activation_key["id"]})
        self.assertEqual(result.return_code, 0, "Failed to get info for activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")
        self.assertEqual(
            result.stdout["host-collections"][0]["name"], test_data["host-col"], "Activation key host-collection added"
        )

        result = ActivationKey.remove_host_collection(
            {u"name": activation_key["name"], u"host-collection": new_host_col["name"], u"organization-id": org["id"]}
        )
        self.assertEqual(result.return_code, 0, "Failed to remove host-col activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")

        result = ActivationKey.info({u"id": activation_key["id"]})
        self.assertEqual(result.return_code, 0, "Failed to get info for activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")
        self.assertEqual(len(result.stdout["host-collections"]), 0, "Activation key host-collection removed")
示例#28
0
    def test_remove_hc_by_name(self):
        """@Test: Test that hosts associated to Activation Keys can be removed
        using name of that host collection

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate host collection to Activation key
        4. Remove the host collection associated to Activation key using name
           of that collection

        @Assert: Host collection successfully removed from activation key

        """
        for host_col in valid_data_list():
            with self.subTest(host_col):
                activation_key = self._make_activation_key()
                new_host_col = make_host_collection({
                    u'name': host_col,
                    u'organization-id': self.org['id'],
                })
                # Assert that name matches data passed
                self.assertEqual(new_host_col['name'], host_col)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 1)
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col,
                )
                ActivationKey.remove_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 0)
    def test_positive_create_with_limit(self):
        """Check if host collection can be created with correct limits

        :id: 682b5624-1095-48e6-a0dd-c76e70ca6540

        :expectedresults: Host collection is created and has expected limits

        :CaseImportance: Critical
        """
        for limit in ('1', '3', '5', '10', '20'):
            with self.subTest(limit):
                new_host_col = make_host_collection({
                    'max-hosts': limit,
                    'organization-id': self.organization['id'],
                })
                self.assertEqual(new_host_col['limit'], limit)
    def test_positive_create_with_description(self):
        """Check if host collection can be created with random description

        :id: 9736e3aa-bbc1-4c5f-98e9-b9dd18ba47ca

        :expectedresults: Host collection is created and has expected
            description

        :CaseImportance: Critical
        """
        for desc in valid_data_list():
            with self.subTest(desc):
                new_host_col = make_host_collection({
                    'description': desc,
                    'organization-id': self.organization['id'],
                })
                self.assertEqual(new_host_col['description'], desc)