Esempio n. 1
0
    def test_update_location_with_multiple_host_group_to_multiple(self):
        """@Test: Create location with multiple (three) host groups assigned to
        it. Try to update location and overwrite all host groups by new
        multiple (two) host groups. Use host groups name as a parameter

        @Feature: Location

        @Assert: Location updated successfully and has correct and expected
        host groups assigned to it

        """
        host_groups = [make_hostgroup() for _ in range(3)]
        loc = make_location({
            'hostgroups': [hg['name'] for hg in host_groups],
        })
        self.assertEqual(len(loc['hostgroups']), 3)
        for host_group in host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
        new_host_groups = [make_hostgroup() for _ in range(2)]
        Location.update({
            'hostgroups': [hg['name'] for hg in new_host_groups],
            'id': loc['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['hostgroups']), 2)
        for host_group in new_host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
Esempio n. 2
0
    def test_positive_update_from_compresources_to_compresource(self):
        """Create location with multiple (not less than three) compute
        resources assigned to it. Try to update location and overwrite all
        compute resources with a new single compute resource. Use compute
        resource id as a parameter

        :id: 3a547413-53dc-4305-84e9-8db7a6bed3b2

        :expectedresults: Location updated successfully and has correct compute
            resource assigned to it

        :CaseImportance: Critical
        """
        resources_amount = randint(3, 5)
        resources = [make_compute_resource() for _ in range(resources_amount)]
        loc = make_location({
            'compute-resource-ids': [resource['id'] for resource in resources],
        })
        self.assertEqual(len(loc['compute-resources']), resources_amount)
        for resource in resources:
            self.assertIn(resource['name'], loc['compute-resources'])

        new_resource = make_compute_resource()
        Location.update({
            'compute-resource-ids': new_resource['id'],
            'id': loc['id'],
        })

        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['compute-resources']), 1)
        self.assertEqual(loc['compute-resources'][0], new_resource['name'])
Esempio n. 3
0
    def test_positive_update_from_hostgroups_to_hostgroups(self):
        """Create location with multiple (three) host groups assigned to
        it. Try to update location and overwrite all host groups by new
        multiple (two) host groups. Use host groups name as a parameter

        :id: e53504d0-8328-485c-bc8c-36ea9a2ad3e1

        :expectedresults: Location updated successfully and has correct and
            expected host groups assigned to it

        :CaseImportance: Critical
        """
        host_groups = [make_hostgroup() for _ in range(3)]
        loc = make_location({
            'hostgroups': [hg['name'] for hg in host_groups],
        })
        self.assertEqual(len(loc['hostgroups']), 3)
        for host_group in host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
        new_host_groups = [make_hostgroup() for _ in range(2)]
        Location.update({
            'hostgroups': [hg['name'] for hg in new_host_groups],
            'id': loc['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['hostgroups']), 2)
        for host_group in new_host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
Esempio n. 4
0
    def test_update_location_with_multiple_comp_resources_to_single(self):
        """@Test: Create location with multiple (not less than three) compute
        resources assigned to it. Try to update location and overwrite all
        compute resources with a new single compute resource. Use compute
        resource id as a parameter

        @Feature: Location

        @Assert: Location updated successfully and has correct compute resource
        assigned to it

        """
        resources_amount = randint(3, 5)
        resources = [make_compute_resource() for _ in range(resources_amount)]
        loc = make_location({
            'compute-resource-ids': [resource['id'] for resource in resources],
        })
        self.assertEqual(len(loc['compute-resources']), resources_amount)
        for resource in resources:
            self.assertIn(resource['name'], loc['compute-resources'])

        new_resource = make_compute_resource()
        Location.update({
            'compute-resource-ids': new_resource['id'],
            'id': loc['id'],
        })

        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['compute-resources']), 1)
        self.assertEqual(loc['compute-resources'][0], new_resource['name'])
Esempio n. 5
0
    def test_positive_update_from_hostgroups_to_hostgroups(self):
        """Create location with multiple (three) host groups assigned to
        it. Try to update location and overwrite all host groups by new
        multiple (two) host groups. Use host groups name as a parameter

        @Feature: Location

        @Assert: Location updated successfully and has correct and expected
        host groups assigned to it

        """
        host_groups = [make_hostgroup() for _ in range(3)]
        loc = make_location({
            'hostgroups': [hg['name'] for hg in host_groups],
        })
        self.assertEqual(len(loc['hostgroups']), 3)
        for host_group in host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
        new_host_groups = [make_hostgroup() for _ in range(2)]
        Location.update({
            'hostgroups': [hg['name'] for hg in new_host_groups],
            'id': loc['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['hostgroups']), 2)
        for host_group in new_host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
Esempio n. 6
0
    def test_positive_update_from_compresources_to_compresource(self):
        """Create location with multiple (not less than three) compute
        resources assigned to it. Try to update location and overwrite all
        compute resources with a new single compute resource. Use compute
        resource id as a parameter

        @Feature: Location

        @Assert: Location updated successfully and has correct compute resource
        assigned to it

        """
        resources_amount = randint(3, 5)
        resources = [make_compute_resource() for _ in range(resources_amount)]
        loc = make_location({
            'compute-resource-ids': [resource['id'] for resource in resources],
        })
        self.assertEqual(len(loc['compute-resources']), resources_amount)
        for resource in resources:
            self.assertIn(resource['name'], loc['compute-resources'])

        new_resource = make_compute_resource()
        Location.update({
            'compute-resource-ids': new_resource['id'],
            'id': loc['id'],
        })

        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['compute-resources']), 1)
        self.assertEqual(loc['compute-resources'][0], new_resource['name'])
Esempio n. 7
0
    def test_negative_update_parent_with_child(self):
        """Attempt to set child location as a parent and vice versa

        :id: fd4cb1cf-377f-4b48-b7f4-d4f6ca56f544

        :customerscenario: true

        :BZ: 1299802

        :expectedresults: Location was not updated

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})

        # set parent as child
        with self.assertRaises(CLIReturnCodeError):
            Location.update({'id': parent_loc['id'], 'parent-id': loc['id']})
        parent_loc = Location.info({'id': parent_loc['id']})
        self.assertIsNone(parent_loc.get('parent'))

        # set child as parent
        with self.assertRaises(CLIReturnCodeError):
            Location.update({'id': loc['id'], 'parent-id': loc['id']})
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['parent'], parent_loc['name'])
Esempio n. 8
0
    def test_negative_update_parent_with_child(self, request):
        """Attempt to set child location as a parent and vice versa

        :id: fd4cb1cf-377f-4b48-b7f4-d4f6ca56f544

        :customerscenario: true

        :BZ: 1299802

        :expectedresults: Location was not updated

        :CaseImportance: High
        """
        parent_location = _location(request)
        location = _location(request, {'parent-id': parent_location['id']})

        # set parent as child
        with pytest.raises(CLIReturnCodeError):
            Location.update({
                'id': parent_location['id'],
                'parent-id': location['id']
            })
        parent_location = Location.info({'id': parent_location['id']})
        assert parent_location.get('parent') is None

        # set child as parent
        with pytest.raises(CLIReturnCodeError):
            Location.update({
                'id': location['id'],
                'parent-id': location['id']
            })
        location = Location.info({'id': location['id']})
        assert location['parent'] == parent_location['name']
Esempio n. 9
0
    def test_positive_update_from_compresources_to_compresource(self):
        """Create location with multiple (not less than three) compute
        resources assigned to it. Try to update location and overwrite all
        compute resources with a new single compute resource. Use compute
        resource id as a parameter

        :id: 3a547413-53dc-4305-84e9-8db7a6bed3b2

        :expectedresults: Location updated successfully and has correct compute
            resource assigned to it

        :CaseImportance: Critical
        """
        resources_amount = randint(3, 5)
        resources = [make_compute_resource() for _ in range(resources_amount)]
        loc = make_location({
            'compute-resource-ids': [resource['id'] for resource in resources],
        })
        self.assertEqual(len(loc['compute-resources']), resources_amount)
        for resource in resources:
            self.assertIn(resource['name'], loc['compute-resources'])

        new_resource = make_compute_resource()
        Location.update({
            'compute-resource-ids': new_resource['id'],
            'id': loc['id'],
        })

        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['compute-resources']), 1)
        self.assertEqual(loc['compute-resources'][0], new_resource['name'])
Esempio n. 10
0
    def test_positive_update_from_hostgroups_to_hostgroups(self):
        """Create location with multiple (three) host groups assigned to
        it. Try to update location and overwrite all host groups by new
        multiple (two) host groups. Use host groups name as a parameter

        :id: e53504d0-8328-485c-bc8c-36ea9a2ad3e1

        :expectedresults: Location updated successfully and has correct and
            expected host groups assigned to it

        :CaseImportance: Critical
        """
        host_groups = [make_hostgroup() for _ in range(3)]
        loc = make_location({
            'hostgroups': [hg['name'] for hg in host_groups],
        })
        self.assertEqual(len(loc['hostgroups']), 3)
        for host_group in host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
        new_host_groups = [make_hostgroup() for _ in range(2)]
        Location.update({
            'hostgroups': [hg['name'] for hg in new_host_groups],
            'id': loc['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['hostgroups']), 2)
        for host_group in new_host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
Esempio n. 11
0
    def test_update_location_with_domain_by_id_negative(self):
        """@Test: Try to update existing location with incorrect domain. Use
        domain id as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'domain-ids': gen_string('numeric', 6),
                'id': loc['id'],
            })
Esempio n. 12
0
    def test_update_location_with_template_by_name_negative(self):
        """@Test: Try to update existing location with incorrect config
        template. Use template name as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'config-templates': gen_string('utf8', 80),
                'id': loc['id'],
            })
Esempio n. 13
0
    def test_negative_update_with_domain_by_id(self):
        """Try to update existing location with incorrect domain. Use
        domain id as a parameter

        @id: ec49ea4d-754a-4958-8180-f61eb6d8cede

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'domain-ids': gen_string('numeric', 6),
                'id': loc['id'],
            })
Esempio n. 14
0
    def test_negative_update_with_domain_by_id(self):
        """Try to update existing location with incorrect domain. Use
        domain id as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'domain-ids': gen_string('numeric', 6),
                'id': loc['id'],
            })
Esempio n. 15
0
    def test_negative_update_with_template_by_name(self):
        """Try to update existing location with incorrect config
        template. Use template name as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'config-templates': gen_string('utf8', 80),
                'id': loc['id'],
            })
Esempio n. 16
0
    def test_negative_update_with_template_by_name(self):
        """Try to update existing location with incorrect config
        template. Use template name as a parameter

        @id: 937730ff-bb46-437b-bfc7-915045d1782c

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'config-templates': gen_string('utf8', 80),
                'id': loc['id'],
            })
Esempio n. 17
0
    def test_negative_update_with_name(self):
        """Try to update location using invalid names only

        @Feature: Location

        @Assert: Location is not updated

        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                loc = make_location()
                with self.assertRaises(CLIReturnCodeError):
                    Location.update({
                        'id': loc['id'],
                        'new-name': invalid_name,
                    })
Esempio n. 18
0
    def test_update_location_with_subnet_by_name(self):
        """@Test: Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        @Feature: Location

        @Assert: Location is updated successfully and has correct subnet with
        expected network address assigned to it

        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])

        result = Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        self.assertEqual(result.return_code, 0)

        result = Location.info({'id': loc['id']})
        self.assertEqual(result.return_code, 0)
        self.assertIn(subnet[1]['name'], result.stdout['subnets'][0])
        self.assertIn(subnet[1]['network'], result.stdout['subnets'][0])
Esempio n. 19
0
    def test_negative_update_with_name(self):
        """Try to update location using invalid names only

        @id: a41abf03-61ca-4201-8a80-7062a6196851

        @Assert: Location is not updated

        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                loc = make_location()
                with self.assertRaises(CLIReturnCodeError):
                    Location.update({
                        'id': loc['id'],
                        'new-name': invalid_name,
                    })
Esempio n. 20
0
    def test_update_location_with_different_names_negative(self):
        """@Test: Try to update location using invalid names only

        @Feature: Location

        @Assert: Location is not updated

        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                loc = make_location()
                with self.assertRaises(CLIReturnCodeError):
                    Location.update({
                        'id': loc['id'],
                        'new-name': invalid_name,
                    })
Esempio n. 21
0
    def test_negative_update_with_template_by_name(self):
        """Try to update existing location with incorrect config
        template. Use template name as a parameter

        :id: 937730ff-bb46-437b-bfc7-915045d1782c

        :expectedresults: Location is not updated


        :CaseImportance: Critical
        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'config-templates': gen_string('utf8', 80),
                'id': loc['id'],
            })
Esempio n. 22
0
    def test_negative_update_with_domain_by_id(self):
        """Try to update existing location with incorrect domain. Use
        domain id as a parameter

        :id: ec49ea4d-754a-4958-8180-f61eb6d8cede

        :expectedresults: Location is not updated


        :CaseImportance: Critical
        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'domain-ids': gen_string('numeric', 6),
                'id': loc['id'],
            })
Esempio n. 23
0
    def test_update_location_with_different_names(self):
        """@Test: Try to update location using different value types as a name

        @Feature: Location

        @Assert: Location is updated successfully and has proper and expected
        name

        """
        loc = make_location()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Location.update({
                    'id': loc['id'],
                    'new-name': new_name,
                })
                loc = Location.info({'id': loc['id']})
                self.assertEqual(loc['name'], new_name)
Esempio n. 24
0
    def test_positive_update_with_name(self):
        """Try to update location using different value types as a name

        @id: 09fa55a5-c688-4bd3-94df-8ab7a2ccda84

        @Assert: Location is updated successfully and has proper and expected
        name

        """
        loc = make_location()
        for new_name in valid_loc_data_list():
            with self.subTest(new_name):
                Location.update({
                    'id': loc['id'],
                    'new-name': new_name,
                })
                loc = Location.info({'id': loc['id']})
                self.assertEqual(loc['name'], new_name)
Esempio n. 25
0
    def test_positive_update_with_name(self):
        """Try to update location using different value types as a name

        @Feature: Location

        @Assert: Location is updated successfully and has proper and expected
        name

        """
        loc = make_location()
        for new_name in valid_loc_data_list():
            with self.subTest(new_name):
                Location.update({
                    'id': loc['id'],
                    'new-name': new_name,
                })
                loc = Location.info({'id': loc['id']})
                self.assertEqual(loc['name'], new_name)
Esempio n. 26
0
    def test_negative_update_with_name(self):
        """Try to update location using invalid names only

        :id: a41abf03-61ca-4201-8a80-7062a6196851

        :expectedresults: Location is not updated


        :CaseImportance: Critical
        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                loc = make_location()
                with self.assertRaises(CLIReturnCodeError):
                    Location.update({
                        'id': loc['id'],
                        'new-name': invalid_name,
                    })
Esempio n. 27
0
    def test_positive_update_parent(self):
        """Update location's parent location

        :id: 34522d1a-1190-48d8-9285-fc9a9bcf6c6a

        :customerscenario: true

        :BZ: 1299802

        :expectedresults: Location was updated successfully

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})
        new_parent_loc = make_location()
        Location.update({'id': loc['id'], 'parent-id': new_parent_loc['id']})
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['parent'], new_parent_loc['name'])
Esempio n. 28
0
    def test_positive_update_with_name(self):
        """Try to update location using different value types as a name

        :id: 09fa55a5-c688-4bd3-94df-8ab7a2ccda84

        :expectedresults: Location is updated successfully and has proper and
            expected name

        :CaseImportance: Critical
        """
        loc = make_location()
        for new_name in valid_loc_data_list():
            with self.subTest(new_name):
                Location.update({
                    'id': loc['id'],
                    'new-name': new_name,
                })
                loc = Location.info({'id': loc['id']})
                self.assertEqual(loc['name'], new_name)
Esempio n. 29
0
    def test_positive_update_with_user_by_id(self):
        """Create new location with assigned user to it. Try to update
        that location and change assigned user on another one. Use user id as a
        parameter

        @Feature: Location

        @Assert: Location is updated successfully and has correct user assigned
        to it

        """
        user = [make_user() for _ in range(2)]
        loc = make_location({'user-ids': user[0]['id']})
        self.assertEqual(loc['users'][0], user[0]['login'])
        Location.update({
            'id': loc['id'],
            'user-ids': user[1]['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['users'][0], user[1]['login'])
Esempio n. 30
0
    def test_update_location_with_user_by_id(self):
        """@Test: Create new location with assigned user to it. Try to update
        that location and change assigned user on another one. Use user id as a
        parameter

        @Feature: Location

        @Assert: Location is updated successfully and has correct user assigned
        to it

        """
        user = [make_user() for _ in range(2)]
        loc = make_location({'user-ids': user[0]['id']})
        self.assertEqual(loc['users'][0], user[0]['login'])
        Location.update({
            'id': loc['id'],
            'user-ids': user[1]['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['users'][0], user[1]['login'])
Esempio n. 31
0
    def test_positive_update_with_user_by_id(self):
        """Create new location with assigned user to it. Try to update
        that location and change assigned user on another one. Use user id as a
        parameter

        @id: 123a8a28-f81d-439a-82d0-5c3d814d1a25

        @Assert: Location is updated successfully and has correct user assigned
        to it

        """
        user = [make_user() for _ in range(2)]
        loc = make_location({'user-ids': user[0]['id']})
        self.assertEqual(loc['users'][0], user[0]['login'])
        Location.update({
            'id': loc['id'],
            'user-ids': user[1]['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['users'][0], user[1]['login'])
Esempio n. 32
0
    def test_positive_update_parent(self, request):
        """Update location's parent location

        :id: 34522d1a-1190-48d8-9285-fc9a9bcf6c6a

        :customerscenario: true

        :BZ: 1299802

        :expectedresults: Location was updated successfully

        :CaseImportance: High
        """
        parent_location = _location(request)
        location = _location(request, {'parent-id': parent_location['id']})

        parent_location_2 = _location(request)
        Location.update({'id': location['id'], 'parent-id': parent_location_2['id']})
        location = Location.info({'id': location['id']})
        assert location['parent'] == parent_location_2['name']
Esempio n. 33
0
    def test_negative_update_parent_with_self(self):
        """Attempt to set a location as its own parent

        :id: 26e07124-9043-4597-8513-7147135a8426

        :BZ: 1299802

        :expectedresults: Location was not updated

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'id': loc['id'],
                'parent-id': loc['id'],
            })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['parent'], parent_loc['name'])
Esempio n. 34
0
    def test_negative_update_parent_with_child(self):
        """Attempt to set child location as a parent

        :id: fd4cb1cf-377f-4b48-b7f4-d4f6ca56f544

        :BZ: 1299802

        :expectedresults: Location was not updated

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'id': parent_loc['id'],
                'parent-id': loc['id'],
            })
        parent_loc = Location.info({'id': parent_loc['id']})
        self.assertIsNone(parent_loc.get('parent'))
Esempio n. 35
0
    def test_positive_update_parent(self):
        """Update location's parent location

        :id: 34522d1a-1190-48d8-9285-fc9a9bcf6c6a

        :BZ: 1299802

        :expectedresults: Location was updated successfully

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})
        new_parent_loc = make_location()
        Location.update({
            'id': loc['id'],
            'parent-id': new_parent_loc['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['parent'], new_parent_loc['name'])
Esempio n. 36
0
    def test_positive_update_with_user_by_id(self):
        """Create new location with assigned user to it. Try to update
        that location and change assigned user on another one. Use user id as a
        parameter

        :id: 123a8a28-f81d-439a-82d0-5c3d814d1a25

        :expectedresults: Location is updated successfully and has correct user
            assigned to it

        :CaseImportance: Critical
        """
        user = [make_user() for _ in range(2)]
        loc = make_location({'user-ids': user[0]['id']})
        self.assertEqual(loc['users'][0], user[0]['login'])
        Location.update({
            'id': loc['id'],
            'user-ids': user[1]['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['users'][0], user[1]['login'])
Esempio n. 37
0
    def test_negative_update_parent_with_self(self):
        """Attempt to set a location as its own parent

        :id: 26e07124-9043-4597-8513-7147135a8426

        :customerscenario: true

        :BZ: 1299802

        :expectedresults: Location was not updated

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'id': loc['id'],
                'parent-id': loc['id'],
            })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(loc['parent'], parent_loc['name'])
Esempio n. 38
0
    def test_positive_update_with_subnet_by_name(self):
        """Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        @id: 2bb2ec4a-2423-46a8-8772-a263823640df

        @Assert: Location is updated successfully and has correct subnet with
        expected network address assigned to it

        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])
        Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertIn(subnet[1]['name'], loc['subnets'][0])
        self.assertIn(subnet[1]['network'], loc['subnets'][0])
Esempio n. 39
0
    def test_positive_update_with_subnet_by_name(self):
        """Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        @Feature: Location

        @Assert: Location is updated successfully and has correct subnet with
        expected network address assigned to it

        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])
        Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertIn(subnet[1]['name'], loc['subnets'][0])
        self.assertIn(subnet[1]['network'], loc['subnets'][0])
Esempio n. 40
0
    def test_positive_update_with_subnet_by_name(self):
        """Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        :id: 2bb2ec4a-2423-46a8-8772-a263823640df

        :expectedresults: Location is updated successfully and has correct
            subnet with expected network address assigned to it

        :CaseImportance: Critical
        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])
        Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertIn(subnet[1]['name'], loc['subnets'][0])
        self.assertIn(subnet[1]['network'], loc['subnets'][0])
Esempio n. 41
0
    def test_update_location_with_different_names_negative(self, name):
        """@Test: Try to update location using invalid names only

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()

        result = Location.update({
            'id': loc['id'],
            'new-name': name,
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Esempio n. 42
0
    def test_update_location_with_domain_by_id_negative(self):
        """@Test: Try to update existing location with incorrect domain. Use
        domain id as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        result = Location.update({
            'id': loc['id'],
            'domain-ids': gen_string('numeric', 6),
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Esempio n. 43
0
    def test_update_location_with_template_by_name_negative(self):
        """@Test: Try to update existing location with incorrect config
        template. Use template name as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        result = Location.update({
            'id': loc['id'],
            'config-templates': gen_string('utf8', 80),
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Esempio n. 44
0
    def test_update_location_with_different_names(self, name):
        """@Test: Try to update location using different value types as a name

        @Feature: Location

        @Assert: Location is updated successfully and has proper and expected
        name

        """
        loc = make_location()
        self.assertNotEqual(loc['name'], name)

        result = Location.update({
            'id': loc['id'],
            'new-name': name,
        })
        self.assertEqual(result.return_code, 0)

        result = Location.info({'id': loc['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['name'], name)
Esempio n. 45
0
    def test_positive_create_update_delete(self, request):
        """Create new location with attributes, update and delete it

        :id: e1844d9d-ec4a-44b3-9743-e932cc70020d

        :BZ: 1233612, 1234287

        :expectedresults: Location created successfully and has expected and
            correct attributes. Attributes can be updated and the location
            can be deleted.

        :CaseImportance: Critical
        """
        # Create
        description = gen_string('utf8')

        subnet = _subnet(request)
        environments = [_environment(request) for _ in range(0, 2)]
        domains = [_domain(request) for _ in range(0, 2)]
        host_groups = [_host_group(request) for _ in range(0, 3)]
        medium = _medium(request)
        compute_resource = _compute_resource(request)
        template = _template(request)
        user = _user(request)

        location = _location(
            request,
            {
                'description': description,
                'subnet-ids': subnet['id'],
                'puppet-environment-ids': environments[0]['id'],
                'domain-ids': [domains[0]['id'], domains[1]['id']],
                'hostgroup-ids': [host_groups[0]['id'], host_groups[1]['id']],
                'medium-ids': medium['id'],
                'compute-resource-ids': compute_resource['id'],
                'provisioning-templates': template['name'],
                'user-ids': user['id'],
            },
        )

        assert location['description'][0] == description
        assert location['subnets'][0] == (
            f"{subnet['name']} ({subnet['network-addr']}/{subnet['network-prefix']})"
        )
        assert location['environments'][0] == environments[0]['name']
        assert domains[0]['name'] in location['domains']
        assert domains[1]['name'] in location['domains']
        assert host_groups[0]['name'] in location['hostgroups']
        assert host_groups[1]['name'] in location['hostgroups']
        assert len(location['installation-media']) > 0
        assert location['installation-media'][0] == medium['name']
        assert location['compute-resources'][0] == compute_resource['name']
        assert len(location['templates']) >= 1

        template_search = ((f"{template['name']} ({template['type']})")
                           if template.get('type') else template['name'])

        assert template_search in location['templates']
        assert location['users'][0] == user['login']

        # Update
        Location.update({
            'id':
            location['id'],
            'puppet-environment-ids':
            [environments[0]['id'], environments[1]['id']],
            'domain-ids':
            domains[1]['id'],
            'hostgroup-ids': [host_groups[1]['id'], host_groups[2]['id']],
        })
        location = Location.info({'id': location['id']})
        assert host_groups[1]['name'] in location['hostgroups']
        assert host_groups[2]['name'] in location['hostgroups']
        assert location['domains'][0] == domains[1]['name']
        assert environments[0]['name'] in location['environments']
        assert environments[1]['name'] in location['environments']

        # Delete
        Location.delete({'id': location['id']})
        with pytest.raises(CLIReturnCodeError):
            Location.info({'id': location['id']})
Esempio n. 46
0
    def test_positive_create_update_delete(self):
        """Create new location with attributes, update and delete it

        :id: e1844d9d-ec4a-44b3-9743-e932cc70020d

        :BZ: 1233612, 1234287

        :expectedresults: Location created successfully and has expected and
            correct attributes. Attributes can be updated and the location
            can be deleted.

        :CaseImportance: Critical
        """
        # Create
        description = gen_string('utf8')
        loc = make_location({
            'description':
            description,
            'subnet-ids':
            self.subnet.id,
            'puppet-environment-ids':
            self.env.id,
            'domain-ids': [self.domain.id, self.domain2.id],
            'hostgroup-ids': [self.host_group.id, self.host_group2.id],
            'medium-ids':
            self.medium["id"],
            'compute-resource-ids':
            self.comp_resource.id,
            'provisioning-templates':
            self.template.name,
            'user-ids':
            self.user.id,
        })

        self.assertEqual(loc['description'][0], description)
        self.assertIn(self.subnet.name, loc['subnets'][0])
        self.assertIn(self.subnet.network, loc['subnets'][0])
        self.assertEqual(loc['environments'][0], self.env.name)
        self.assertIn(self.domain.name, loc['domains'])
        self.assertIn(self.domain2.name, loc['domains'])
        self.assertIn(self.host_group.name, loc['hostgroups'])
        self.assertIn(self.host_group2.name, loc['hostgroups'])
        self.assertGreater(len(loc['installation-media']), 0)
        self.assertEqual(loc['installation-media'][0], self.medium['name'])
        self.assertEqual(loc['compute-resources'][0], self.comp_resource.name)
        self.assertGreaterEqual(len(loc['templates']), 1)
        # templates are returned as `name (type)` or just `name` if type is unset
        if self.template.template_kind is None:
            template_search = self.template.name
        else:
            template_search = '{} ({})'.format(
                self.template.name,
                entities.TemplateKind().search()[0].name)
        self.assertIn(template_search, loc['templates'])
        self.assertEqual(loc['users'][0], self.user.login)

        # Update
        Location.update({
            'id':
            loc['id'],
            'puppet-environment-ids': [self.env.id, self.env2.id],
            'domain-ids':
            self.domain2.id,
            'hostgroup-ids': [self.host_group2.id, self.host_group3.id],
        })
        loc = Location.info({'id': loc['id']})
        self.assertIn(self.host_group2.name, loc['hostgroups'])
        self.assertIn(self.host_group3.name, loc['hostgroups'])
        self.assertEqual(loc['domains'][0], self.domain2.name)
        self.assertIn(self.env.name, loc['environments'])
        self.assertIn(self.env2.name, loc['environments'])

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