Esempio n. 1
0
    def test_negative_create_1(self, test_data):
        """
        @test: Create Operating System using invalid names
        @feature: Operating System - Negative Create
        @assert: Operating System is not created
        """

        with self.assertRaises(Exception):
            make_os(test_data)
    def test_negative_create_with_name(self):
        """Create Operating System using invalid names

        @id: 848a20ce-292a-47d8-beea-da5916c43f11

        @assert: Operating System is not created
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIFactoryError):
                    make_os({'name': name})
Esempio n. 3
0
    def test_negative_create_with_name(self):
        """@test: Create Operating System using invalid names

        @feature: Operating System

        @assert: Operating System is not created
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIFactoryError):
                    make_os({'name': name})
Esempio n. 4
0
    def test_negative_create_with_name(self):
        """Create Operating System using invalid names

        :id: 848a20ce-292a-47d8-beea-da5916c43f11

        :expectedresults: Operating System is not created

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIFactoryError):
                    make_os({'name': name})
Esempio n. 5
0
    def test_positive_update_os_by_name(self):
        """A host can be updated with a new operating system. Use
        entities names for association

        @id: bd48887f-3db3-47b0-8231-de58884efe57

        @assert: A host is updated and the operating system matches

        @CaseLevel: Integration
        """
        new_os = make_os({
            'architectures': self.host_args.architecture.name,
            'partition-tables': self.host[
                'operating-system']['partition-table'],
        })
        Medium.add_operating_system({
            'name': self.host_args.medium.name,
            'operatingsystem': new_os['title'],
        })
        Host.update({
            'name': self.host['name'],
            'operatingsystem': new_os['title'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(
            self.host['operating-system']['operating-system'], new_os['title'])
Esempio n. 6
0
    def test_negative_delete_1(self, test_data):
        """@test: Not delete Operating System for invalid data

        @feature: Operating System - Negative Delete

        @assert: Operating System is not deleted

        """

        # Create a new object using default values
        new_obj = make_os()

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")

        # The delete method requires the ID which we will not pass
        result = OperatingSys.delete(test_data)
        self.assertNotEqual(result.return_code, 0, "Should not delete object")
        self.assertGreater(
            len(result.stderr), 0, "Should have gotten an error")

        # Now make sure that it still exists
        result = OperatingSys.info({'id': new_obj['id']})
        self.assertTrue(result.return_code == 0, "Failed to find object")
        self.assertEqual(new_obj['id'], result.stdout['id'])
        self.assertEqual(new_obj['name'], result.stdout['name'])
Esempio n. 7
0
    def test_positive_delete_1(self, test_data):
        """@test: Successfully deletes Operating System

        @feature: Operating System - Positive Delete

        @assert: Operating System is deleted

        """

        # Create a new object passing @test_data to factory method
        new_obj = make_os(test_data)

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")

        # Now delete it...
        result = OperatingSys.delete(
            {'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to delete object")
        self.assertEqual(len(result.stderr), 0, "Should not get an error.")
        # ... and make sure it does not exist anymore
        result = OperatingSys.info({'id': new_obj['id']})
        self.assertNotEqual(
            result.return_code, 0, "Return code should not be zero")
        self.assertGreater(
            len(result.stderr), 0, "Should have gotten an error")
        self.assertEqual(result.stdout, {}, "Should not get any output")
Esempio n. 8
0
    def test_negative_update_1(self, test_data):
        """@test: Negative update of system name

        @feature: Operating System - Negative Update

        @assert: Operating System is not updated

        """

        # "Unpacks" values from tuple
        orig_dict, updates_dict = test_data

        # Create a new object passing @test_data to factory method
        new_obj = make_os(orig_dict)

        # Update original data with new values
        updates_dict['id'] = new_obj['id']
        orig_dict.update(updates_dict)

        # Now update the Foreman object
        result = OperatingSys.update(orig_dict)
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)

        # OS should not have changed
        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])
Esempio n. 9
0
    def test_add_ptable(self):
        """@test: Add ptable to os

        @feature: Operating System - Add ptable

        @assert: Operating System is updated with ptable

        """
        # Create a partition table.
        ptable_name = make_partition_table()['name']
        # Create an operating system.
        os_id = make_os()['id']

        # Add the partition table to the operating system.
        response = OperatingSys.add_ptable({
            'id': os_id,
            'partition-table': ptable_name,
        })
        self.assertEqual(response.return_code, 0)
        self.assertEqual(len(response.stderr), 0)

        # Verify that the operating system has a partition table.
        response = OperatingSys.info({'id': os_id})
        self.assertEqual(len(response.stdout['partition-tables']), 1)
        self.assertEqual(response.stdout['partition-tables'][0], ptable_name)
Esempio n. 10
0
    def test_add_operating_system_1(self):
        """@Test: Check if Template can be assigned operating system

        @Feature: Template - Add Operating System

        @Assert: Template has an operating system

        """

        content = gen_string("alpha", 10)
        name = gen_string("alpha", 10)

        try:
            new_template = make_template({
                'name': name,
                'content': content,
            })
            new_os = make_os()
        except CLIFactoryError as err:
            self.fail(err)

        result = Template.add_operatingsystem({
            "id": new_template["id"],
            "operatingsystem-id": new_os["id"],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Template.info({'id': new_template['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, result.stdout['operating-systems'])
Esempio n. 11
0
    def test_add_architecture(self):
        """@test: Add Architecture to os

        @feature: Operating System - Add architecture

        @assert: Operating System is updated with architecture

        """

        a_ob = make_architecture()

        result = Architecture.info({'id': a_ob['id']})
        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")

        new_obj = make_os()
        result = OperatingSys.add_architecture({'id': new_obj['id'],
                                                'architecture-id': a_ob['id']})
        self.assertEqual(result.return_code, 0, "Failed to add architecture")
        self.assertEqual(
            len(result.stderr), 0, "Should not have gotten an error")

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to find object")
        self.assertEqual(len(result.stdout['architectures']), 1)
        self.assertEqual(a_ob['name'], result.stdout['architectures'][0])
Esempio n. 12
0
    def test_bugzilla_1203457(self):
        """@test: Create an OS pointing to an arch, medium and partition table.

        @feature: Operating System - Create

        @assert: An operating system is created.

        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        result = OperatingSys.info({'id': operating_system['id']})
        self.assertEqual(result.return_code, 0)
        stdout = result.stdout
        for attr in (
                'architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(stdout[attr]), 1)
        self.assertEqual(stdout['architectures'][0], architecture['name'])
        self.assertEqual(stdout['installation-media'][0], medium['name'])
        self.assertEqual(stdout['partition-tables'][0], ptable['name'])
Esempio n. 13
0
    def test_negative_update_os(self):
        """A host can not be updated with a operating system, which is
        not associated with host's medium

        @id: ff13d2af-e54a-4daf-a24d-7ec930b4fbbe

        @assert: A host is not updated

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        new_os = make_os({
            'architectures': new_arch['name'],
            'partition-tables': self.host[
                'operating-system']['partition-table'],
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
                'operatingsystem': new_os['title'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(
            self.host['operating-system']['operating-system'], new_os['title'])
Esempio n. 14
0
    def test_add_ptable(self):
        """@test: Add ptable to os

        @feature: Operating System - Add ptable

        @assert: Operating System is updated with ptable

        """

        ptable_obj = make_partition_table()

        result = PartitionTable.info({'id': ptable_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(ptable_obj['name'], result.stdout['name'])

        new_obj = make_os()
        result = OperatingSys.add_ptable({'id': new_obj['id'],
                                          'ptable': ptable_obj['name']})
        self.assertEqual(result.return_code, 0, "Failed to add ptable")
        self.assertEqual(
            len(result.stderr), 0, "Should not have gotten an error")

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to find object")
        self.assertEqual(len(result.stdout['partition-tables']), 1)
        self.assertIn(ptable_obj['name'], result.stdout['partition-tables'][0])
Esempio n. 15
0
    def test_add_configtemplate(self):
        """@test: Add configtemplate to os

        @feature: Operating System - Add comfigtemplate

        @assert: Operating System is updated with config template

        """

        conf_obj = make_template()

        result = Template.info({'id': conf_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(conf_obj['name'], result.stdout['name'])

        new_obj = make_os()
        result = OperatingSys.add_config_template(
            {'id': new_obj['id'],
             'config-template': conf_obj['name']})
        self.assertEqual(result.return_code, 0, "Failed to add configtemplate")
        self.assertEqual(
            len(result.stderr), 0, "Should not have gotten an error")

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to find object")
        self.assertEqual(len(result.stdout['templates']), 1)
        template_name = result.stdout['templates'][0]
        self.assertTrue(template_name.startswith(conf_obj['name']))
Esempio n. 16
0
    def test_addoperatingsystem_medium(self):
        """
        @Test: Check if Medium can be associated with operating system
        @Feature: Medium - Add operating system
        @Assert: Operating system added
        """

        name = generate_name(6)
        try:
            medium = make_medium({'name': name})
        except CLIFactoryError as e:
            self.fail(e)

        try:
            os = make_os()
        except CLIFactoryError as e:
            self.fail(e)

        args = {'id': medium['id'],
                'operatingsystem-id': os['id']}

        result = Medium().add_operating_system(args)
        self.assertEqual(result.return_code, 0,
                         "Could not associate the operating system to media")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an exception here")
    def test_positive_create_with_arch_medium_ptable(self):
        """Create an OS pointing to an arch, medium and partition table.

        @id: 05bdb2c6-0d2e-4141-9e07-3ada3933b577

        @assert: An operating system is created.
        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        for attr in (
                'architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(operating_system[attr]), 1)
        self.assertEqual(
            operating_system['architectures'][0], architecture['name'])
        self.assertEqual(
            operating_system['installation-media'][0], medium['name'])
        self.assertEqual(
            operating_system['partition-tables'][0], ptable['name'])
Esempio n. 18
0
    def test_positive_update_os_by_id(self):
        """A host can be updated with a new operating system. Use
        entities ids for association

        @id: 9ea88634-9c14-4519-be6e-fb163897efb7

        @assert: A host is updated and the operating system matches

        @CaseLevel: Integration
        """
        new_os = make_os({
            'architecture-ids': self.host_args.architecture.id,
            'partition-table-ids': self.host_args.ptable.id,
        })
        Medium.add_operating_system({
            'id': self.host_args.medium.id,
            'operatingsystem-id': new_os['id'],
        })
        Host.update({
            'id': self.host['id'],
            'operatingsystem-id': new_os['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(
            self.host['operating-system']['operating-system'], new_os['title'])
Esempio n. 19
0
    def test_bugzilla_1051557(self):
        """@test: Update an Operating System's major version.

        @feature: Operating System - Update

        @assert: Operating System major version is updated

        @bz: 1021557

        """

        try:
            os = make_os()
        except CLIFactoryError as err:
            self.fail(err)

        # New value for major
        major = int(os['major-version']) + 1

        result = OperatingSys.update(
            {'id': os['id'], 'major': major})
        self.assertEqual(result.return_code, 0,
                         'Failed to update activation key')
        self.assertEqual(len(result.stderr), 0,
                         'There should not be an error here')

        result = OperatingSys.info({
            u'id': os['id'],
        })
        self.assertEqual(result.return_code, 0,
                         'Failed to get info for OS')
        self.assertEqual(len(result.stderr), 0,
                         'There should not be an error here')
        self.assertEqual(int(result.stdout['major-version']), major,
                         'OS major version was not updated')
Esempio n. 20
0
    def test_bugzilla_1051557(self):
        """@test: Update an Operating System's major version.

        @feature: Operating System - Update

        @assert: Operating System major version is updated

        """

        try:
            os = make_os()
        except CLIFactoryError as err:
            self.fail(err)

        # New value for major
        major = int(os['major-version']) + 1

        result = OperatingSys.update(
            {'id': os['id'], 'major': major})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = OperatingSys.info({
            u'id': os['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(int(result.stdout['major-version']), major)
Esempio n. 21
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        :id: b5362565-6dce-4770-81e1-4fe3ec6f6cee

        :expectedresults: Operating system is removed from template

        :CaseLevel: Integration
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 22
0
    def test_bugzilla_1203457(self):
        """@test: Create an OS pointing to an arch, medium and partition table.

        @feature: Operating System - Create

        @assert: An operating system is created.

        @bz: 1203457, 1200116

        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        for attr in (
                'architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(operating_system[attr]), 1)
        self.assertEqual(
            operating_system['architectures'][0], architecture['name'])
        self.assertEqual(
            operating_system['installation-media'][0], medium['name'])
        self.assertEqual(
            operating_system['partition-tables'][0], ptable['name'])
Esempio n. 23
0
    def test_positive_update_1(self, test_data):
        """
        @test: Positive update of system name
        @feature: Operating System - Positive Update
        @assert: Operating System is updated and can be found
        """

        # "Unpacks" values from tuple
        orig_dict, updates_dict = test_data

        # Create a new object passing @test_data to factory method
        new_obj = make_os(orig_dict)

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")

        # Update original test_data with new values
        updates_dict['id'] = new_obj['id']
        orig_dict.update(updates_dict)
        # Now update the Foreman object
        result = OperatingSys.update(orig_dict)
        self.assertEqual(result.return_code, 0, "Failed to update object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")

        result = OperatingSys.info({'id': new_obj['id']})

        # Verify that standard values are correct
        self.assertEqual(
            new_obj['id'], result.stdout['id'], "IDs should match")
        self.assertNotEqual(result.stdout['name'], new_obj['name'])
        # There should be some attributes changed now
        self.assertNotEqual(new_obj, result.stdout, "Object should be updated")
Esempio n. 24
0
    def test_remove_operating_system_1(self):
        """@Test: Check if OS can be removed Template

        @Feature: Template - Remove Operating System

        @Assert: Template no longer has an operating system

        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 25
0
    def test_remove_operating_system_1(self):
        """@Test: Check if OS can be removed Template

        @Feature: Template - Remove Operating System

        @Assert: Template no longer has an operating system

        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        try:
            new_obj = make_template(
                {
                    'name': name,
                    'content': content,
                }
            )
            new_os = make_os()
        except CLIFactoryError as e:
            self.fail(e)

        result = Template.add_operatingsystem(
            {
                "id": new_obj["id"],
                "operatingsystem-id": new_os["id"]
            }
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        os_string = "%s %s.%s" % (
            new_os['name'], new_os['major'], new_os['minor']
        )
        self.assertIn(os_string, result.stdout['operating-systems'])

        result = Template.remove_operatingsystem(
            {
                "id": new_obj["id"],
                "operatingsystem-id": new_os["id"]
            }
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        os_string = "%s %s.%s" % (
            new_os['name'], new_os['major'], new_os['minor']
        )
        self.assertNotIn(os_string, result.stdout['operating-systems'])
Esempio n. 26
0
    def test_positive_create_with_os(self):
        """Check if hostgroup with operating system can be created

        @id: d12c5939-1aac-44f5-8aa3-a04a824f4e83

        @Assert: Hostgroup is created and has operating system assigned

        """
        os = make_os()
        hostgroup = make_hostgroup({'operatingsystem-id': os['id']})
        self.assertEqual(hostgroup['operating-system'], os['title'])
Esempio n. 27
0
    def test_positive_create_with_name(self):
        """@test: Create Operating System for all variations of name

        @feature: Operating System

        @assert: Operating System is created and can be found
        """
        for name in valid_data_list():
            with self.subTest(name):
                os = make_os({'name': name})
                self.assertEqual(os['name'], name)
Esempio n. 28
0
    def test_positive_create_1(self, test_data):
        """@test: Create Operating System for all variations of name

        @feature: Operating System - Positive Create

        @assert: Operating System is created and can be found

        """
        # Create a new object using factory method
        os = make_os(test_data)
        self.assertEqual(os['name'], test_data['name'])
Esempio n. 29
0
    def test_create_hostgroup_with_operating_system(self):
        """@Test: Check if hostgroup with operating system can be created

        @Feature: Hostgroup - Create

        @Assert: Hostgroup is created and has operating system assigned

        """
        os = make_os()
        hostgroup = make_hostgroup({'operatingsystem-id': os['id']})
        self.assertEqual(hostgroup['operating-system'], os['title'])
    def test_positive_create_with_name(self):
        """Create Operating System for all variations of name

        @id: d36eba9b-ccf6-4c9d-a07f-c74eebada89b

        @assert: Operating System is created and can be found
        """
        for name in valid_data_list():
            with self.subTest(name):
                os = make_os({'name': name})
                self.assertEqual(os['name'], name)
Esempio n. 31
0
    def test_negative_update_name(self, new_name):
        """Negative update of system name

        :id: 4b18ff6d-7728-4245-a1ce-38e62c05f454

        :parametrized: yes

        :expectedresults: Operating System name is not updated

        :CaseImportance: Critical
        """
        os = make_os({'name': gen_alphanumeric()})
        with pytest.raises(CLIReturnCodeError):
            OperatingSys.update({'id': os['id'], 'name': new_name})
        result = OperatingSys.info({'id': os['id']})
        assert result['name'] == os['name']
Esempio n. 32
0
    def test_positive_update_name(self, new_name):
        """Positive update of operating system name

        :id: 49b655f7-ba9b-4bb9-b09d-0f7140969a40

        :parametrized: yes

        :expectedresults: Operating System name is updated

        :CaseImportance: Critical
        """
        os = make_os({'name': gen_alphanumeric()})
        OperatingSys.update({'id': os['id'], 'name': new_name})
        result = OperatingSys.info({'id': os['id']})
        assert result['id'] == os['id']
        assert result['name'] != os['name']
Esempio n. 33
0
    def test_positive_add_arch(self):
        """Add Architecture to operating system

        @feature: Operating System

        @assert: Architecture is added to Operating System
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
Esempio n. 34
0
    def test_negative_update_name(self):
        """Negative update of system name

        :id: 4b18ff6d-7728-4245-a1ce-38e62c05f454

        :expectedresults: Operating System name is not updated

        :CaseImportance: Critical
        """
        os = make_os({'name': gen_alphanumeric()})
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    OperatingSys.update({'id': os['id'], 'name': new_name})
                result = OperatingSys.info({'id': os['id']})
                self.assertEqual(result['name'], os['name'])
Esempio n. 35
0
    def test_positive_add_os(self):
        """Check if Medium can be associated with operating system

        :id: 47d1e6f0-d8a6-4190-b2ac-41b09a559429

        :expectedresults: Operating system added


        :CaseLevel: Integration
        """
        medium = make_medium()
        os = make_os()
        Medium.add_operating_system({
            'id': medium['id'],
            'operatingsystem-id': os['id']
        })
Esempio n. 36
0
    def test_verify_redmine_4547(self):
        """Search for newly created OS by name

        @feature: Operating System - Search

        @assert: Operating System is created and listed

        @bz: redmine#4547
        """
        os_list_before = OperatingSys.list()
        os = make_os()
        os_list = OperatingSys.list({'search': 'name=%s' % os['name']})
        os_info = OperatingSys.info({'id': os_list[0]['id']})
        self.assertEqual(os['id'], os_info['id'])
        os_list_after = OperatingSys.list()
        self.assertGreater(len(os_list_after), len(os_list_before))
Esempio n. 37
0
    def test_positive_search_by_title(self):
        """Search for newly created OS by title

        :id: a555e848-f1f2-4326-aac6-9de8ff45abee

        :expectedresults: Operating System is created and listed

        :CaseImportance: Critical
        """
        os_list_before = OperatingSys.list()
        os = make_os()
        os_list = OperatingSys.list({'search': 'title=\\"%s\\"' % os['title']})
        os_info = OperatingSys.info({'id': os_list[0]['id']})
        self.assertEqual(os['id'], os_info['id'])
        os_list_after = OperatingSys.list()
        self.assertGreater(len(os_list_after), len(os_list_before))
Esempio n. 38
0
    def test_positive_search_by_name(self):
        """Search for newly created OS by name

        :id: ff9f667c-97ca-49cd-902b-a9b18b5aa021

        :expectedresults: Operating System is created and listed

        :CaseImportance: Critical
        """
        os_list_before = OperatingSys.list()
        os = make_os()
        os_list = OperatingSys.list({'search': 'name=%s' % os['name']})
        os_info = OperatingSys.info({'id': os_list[0]['id']})
        self.assertEqual(os['id'], os_info['id'])
        os_list_after = OperatingSys.list()
        self.assertGreater(len(os_list_after), len(os_list_before))
Esempio n. 39
0
    def test_positive_update_name(self):
        """Positive update of operating system name

        :id: 49b655f7-ba9b-4bb9-b09d-0f7140969a40

        :expectedresults: Operating System name is updated

        :CaseImportance: Critical
        """
        os = make_os({'name': gen_alphanumeric()})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                OperatingSys.update({'id': os['id'], 'name': new_name})
                result = OperatingSys.info({'id': os['id']})
                self.assertEqual(result['id'], os['id'])
                self.assertNotEqual(result['name'], os['name'])
Esempio n. 40
0
    def test_positive_generate_report_sanitized(self):
        """Generate report template where there are values in comma outputted
        which might brake CSV format

        :id: 84b577db-144e-4961-a42e-e93887464986

        :setup: User with reporting access rights, Host Statuses report,
                a host with OS that has comma in its name

        :steps:

            1. hammer report-template generate ...

        :expectedresults: Report is generated in proper CSV format (value with comma is quoted)

        :CaseImportance: Medium
        """
        os_name = gen_string('alpha') + "," + gen_string('alpha')
        architecture = make_architecture()
        partition_table = make_partition_table()
        medium = make_medium()
        os = make_os({
            'name': os_name,
            'architecture-ids': architecture['id'],
            'medium-ids': medium['id'],
            'partition-table-ids': partition_table['id'],
        })

        host_name = gen_string('alpha')
        host = make_fake_host({
            'name': host_name,
            'architecture-id': architecture['id'],
            'medium-id': medium['id'],
            'operatingsystem-id': os['id'],
            'partition-table-id': partition_table['id'],
        })

        report_template = make_report_template(
            {'content': REPORT_TEMPLATE_FILE})

        result = ReportTemplate.generate({'name': report_template['name']})
        self.assertIn('Name,Operating System',
                      result)  # verify header of custom template
        self.assertIn(
            '{0},"{1}"'.format(host['name'],
                               host['operating-system']['operating-system']),
            result)
Esempio n. 41
0
    def test_positive_add_template(self):
        """Add provisioning template to operating system

        @feature: Operating System

        @assert: Provisioning template is added to Operating System
        """
        template = make_template()
        os = make_os()
        OperatingSys.add_config_template({
            'config-template': template['name'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['templates']), 1)
        template_name = os['templates'][0]
        self.assertTrue(template_name.startswith(template['name']))
Esempio n. 42
0
    def test_negative_update_name(self):
        """Negative update of system name

        @feature: Operating System

        @assert: Operating System name is not updated
        """
        os = make_os({'name': gen_alphanumeric()})
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    OperatingSys.update({
                        'id': os['id'],
                        'name': new_name,
                    })
                result = OperatingSys.info({'id': os['id']})
                self.assertEqual(result['name'], os['name'])
    def test_negative_delete_by_id(self):
        """Delete Operating System using invalid data

        @id: d29a9c95-1fe3-4a7a-9f7b-127be065856d

        @assert: Operating System is not deleted
        """
        for test_data in negative_delete_data():
            with self.subTest(test_data):
                os = make_os()
                # The delete method requires the ID which we will not pass
                with self.assertRaises(CLIReturnCodeError):
                    OperatingSys.delete(test_data)
                # Now make sure that it still exists
                result = OperatingSys.info({'id': os['id']})
                self.assertEqual(os['id'], result['id'])
                self.assertEqual(os['name'], result['name'])
Esempio n. 44
0
    def test_negative_delete_by_id(self):
        """Delete Operating System using invalid data

        @feature: Operating System

        @assert: Operating System is not deleted
        """
        for test_data in NEGATIVE_DELETE_DATA:
            with self.subTest(test_data):
                os = make_os()
                # The delete method requires the ID which we will not pass
                with self.assertRaises(CLIReturnCodeError):
                    OperatingSys.delete(test_data)
                # Now make sure that it still exists
                result = OperatingSys.info({'id': os['id']})
                self.assertEqual(os['id'], result['id'])
                self.assertEqual(os['name'], result['name'])
Esempio n. 45
0
    def test_positive_add_os_by_name(self):
        """Create a partition table then add an operating system to it using
        names for association

        :id: ad97800a-0ef8-4ee9-ab49-05c82c77017f

        :expectedresults: Operating system is added to partition table

        :CaseLevel: Integration
        """
        ptable = make_partition_table()
        os = make_os()
        PartitionTable.add_operating_system(
            {'name': ptable['name'], 'operatingsystem': os['title']}
        )
        ptable = PartitionTable.info({'name': ptable['name']})
        self.assertIn(os['title'], ptable['operating-systems'])
Esempio n. 46
0
    def test_positive_list(self):
        """Displays list for operating system

        :id: fca309c5-edff-4296-a800-55470669935a

        :expectedresults: Operating System is created and listed

        :CaseImportance: Critical
        """
        os_list_before = OperatingSys.list()
        name = gen_string('alpha')
        os = make_os({'name': name})
        os_list = OperatingSys.list({'search': 'name=%s' % name})
        os_info = OperatingSys.info({'id': os_list[0]['id']})
        assert os['id'] == os_info['id']
        os_list_after = OperatingSys.list()
        assert len(os_list_after) > len(os_list_before)
    def test_positive_add_template(self):
        """Add provisioning template to operating system

        :id: 0ea9eb88-2d27-423d-a9d3-fdd788b4e28a

        :expectedresults: Provisioning template is added to Operating System

        :CaseLevel: Integration
        """
        template = make_template()
        os = make_os()
        OperatingSys.add_provisioning_template(
            {'provisioning-template': template['name'], 'id': os['id']}
        )
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['templates']), 1)
        template_name = os['templates'][0]
        self.assertTrue(template_name.startswith(template['name']))
    def test_positive_add_arch(self):
        """Add Architecture to operating system

        @id: 99add22d-d936-4232-9441-beff85867040

        @assert: Architecture is added to Operating System

        @CaseLevel: Integration
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
    def test_positive_update_major_version(self):
        """Update an Operating System's major version.

        @id: 38a89dbe-6d1c-4602-a4c1-664425668de8

        @assert: Operating System major version is updated
        """
        os = make_os()
        # New value for major
        major = int(os['major-version']) + 1
        OperatingSys.update({
            'id': os['id'],
            'major': major,
        })
        os = OperatingSys.info({
            'id': os['id'],
        })
        self.assertEqual(int(os['major-version']), major)
Esempio n. 50
0
    def test_positive_update_major_version(self):
        """Update an Operating System's major version.

        @feature: Operating System

        @assert: Operating System major version is updated
        """
        os = make_os()
        # New value for major
        major = int(os['major-version']) + 1
        OperatingSys.update({
            'id': os['id'],
            'major': major,
        })
        os = OperatingSys.info({
            'id': os['id'],
        })
        self.assertEqual(int(os['major-version']), major)
Esempio n. 51
0
    def test_positive_add_remove_os_by_id(self):
        """Create a partition table then add and remove an operating system to it using
        IDs for association

        :id: 33b5ddca-2151-45cb-bf30-951c2733165f

        :expectedresults: Operating system is added to partition table

        :CaseLevel: Integration
        """
        ptable = make_partition_table()
        os = make_os()
        PartitionTable.add_operating_system({'id': ptable['id'], 'operatingsystem-id': os['id']})
        ptable = PartitionTable.info({'id': ptable['id']})
        assert os['title'] in ptable['operating-systems']
        PartitionTable.remove_operating_system({'id': ptable['id'], 'operatingsystem-id': os['id']})
        ptable = PartitionTable.info({'id': ptable['id']})
        assert os['title'] not in ptable['operating-systems']
Esempio n. 52
0
    def test_positive_info_by_id(self):
        """Displays info for operating system by its ID

        :id: b8f23b53-439a-4726-9757-164d99d5ed05

        :expectedresults: Operating System is created and can be looked up by
            its ID

        :CaseImportance: Critical
        """
        os = make_os()
        os_info = OperatingSys.info({'id': os['id']})
        # Info does not return major or minor but a concat of name,
        # major and minor
        assert os['id'] == os_info['id']
        assert os['name'] == os_info['name']
        assert str(os['major-version']) == os_info['major-version']
        assert str(os['minor-version']) == os_info['minor-version']
Esempio n. 53
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        @Feature: Template - Add Operating System

        @Assert: Operating system is added to the template
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(new_os['name'],
                                         new_os['major-version'],
                                         new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 54
0
    def test_positive_add_arch(self):
        """Add Architecture to operating system

        :id: 99add22d-d936-4232-9441-beff85867040

        :expectedresults: Architecture is added to Operating System

        :CaseLevel: Integration
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id']
        })
        os = OperatingSys.info({'id': os['id']})
        assert len(os['architectures']) == 1
        assert architecture['name'] == os['architectures'][0]
Esempio n. 55
0
    def test_positive_add_os_by_id(self):
        """Create a partition table then add an operating system to it using
        IDs for association

        :id: 37415a34-5dba-4551-b1c5-e6e59329f4ca

        :expectedresults: Operating system is added to partition table

        :CaseLevel: Integration
        """
        ptable = make_partition_table()
        os = make_os()
        PartitionTable.add_operating_system({
            'id': ptable['id'],
            'operatingsystem-id': os['id'],
        })
        ptable = PartitionTable.info({'id': ptable['id']})
        self.assertIn(os['title'], ptable['operating-systems'])
Esempio n. 56
0
    def test_positive_add_ptable(self):
        """Add partition table to operating system

        :id: beba676f-b4e4-48e1-bb0c-18ad91847566

        :expectedresults: Partition table is added to Operating System

        :CaseLevel: Integration
        """
        # Create a partition table.
        ptable_name = make_partition_table()['name']
        # Create an operating system.
        os_id = make_os()['id']
        # Add the partition table to the operating system.
        OperatingSys.add_ptable({'id': os_id, 'partition-table': ptable_name})
        # Verify that the operating system has a partition table.
        os = OperatingSys.info({'id': os_id})
        assert len(os['partition-tables']) == 1
        assert os['partition-tables'][0] == ptable_name
Esempio n. 57
0
    def test_negative_delete_by_id(self, test_data):
        """Delete Operating System using invalid data

        :id: d29a9c95-1fe3-4a7a-9f7b-127be065856d

        :parametrized: yes

        :expectedresults: Operating System is not deleted

        :CaseImportance: Critical
        """
        os = make_os()
        # The delete method requires the ID which we will not pass
        with pytest.raises(CLIReturnCodeError):
            OperatingSys.delete(test_data)
        # Now make sure that it still exists
        result = OperatingSys.info({'id': os['id']})
        assert os['id'] == result['id']
        assert os['name'] == result['name']
Esempio n. 58
0
    def test_positive_create_1(self, test_data):
        """@test: Create Operating System for all variations of name

        @feature: Operating System - Positive Create

        @assert: Operating System is created and can be found

        """

        # Create a new object using factory method
        new_obj = make_os(test_data)

        # Can we find the new object?
        result = OperatingSys.info({'id': new_obj['id']})

        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an exception here")
        self.assertEqual(result.stdout['name'], new_obj['name'])
Esempio n. 59
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        @id: d9f481b3-9757-4208-b451-baf4792d4d70

        @Assert: Operating system is added to the template

        @CaseLevel: Integration
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 60
0
def test_positive_generate_report_sanitized():
    """Generate report template where there are values in comma outputted
    which might brake CSV format

    :id: 84b577db-144e-4961-a42e-e93887464986

    :setup: User with reporting access rights, Host Statuses report,
            a host with OS that has comma in its name

    :steps:

        1. hammer report-template generate ...

    :expectedresults: Report is generated in proper CSV format (value with comma is quoted)

    :CaseImportance: Medium
    """
    # create a name that has a comma in it, some randomized text, and no spaces.
    os_name = gen_alpha(start='test', separator=',').replace(' ', '')
    architecture = make_architecture()
    partition_table = make_partition_table()
    medium = make_medium()
    os = make_os({
        'name': os_name,
        'architecture-ids': architecture['id'],
        'medium-ids': medium['id'],
        'partition-table-ids': partition_table['id'],
    })

    host_name = gen_alpha()
    host = make_fake_host({
        'name': host_name,
        'architecture-id': architecture['id'],
        'medium-id': medium['id'],
        'operatingsystem-id': os['id'],
        'partition-table-id': partition_table['id'],
    })

    report_template = make_report_template({'content': REPORT_TEMPLATE_FILE})

    result = ReportTemplate.generate({'name': report_template['name']})
    assert 'Name,Operating System' in result  # verify header of custom template
    assert f'{host["name"]},"{host["operating-system"]["operating-system"]}"' in result