Exemple #1
0
    def test_delete_location_by_id(self):
        """@Test: Try to delete location using id of that location as a
        parameter

        @Feature: Location

        @Assert: Location is deleted successfully

        """
        loc = make_location()
        Location.delete({'id': loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.info({'id': loc['id']})
    def test_positive_delete_by_id(self):
        """Try to delete location using id of that location as a
        parameter

        @id: 71e394e3-85e6-456d-b03d-6787db9059aa

        @Assert: Location is deleted successfully

        """
        loc = make_location()
        Location.delete({'id': loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.info({'id': loc['id']})
Exemple #3
0
    def test_positive_delete_by_id(self):
        """Try to delete location using id of that location as a
        parameter

        :id: 71e394e3-85e6-456d-b03d-6787db9059aa

        :expectedresults: Location is deleted successfully


        :CaseImportance: Critical
        """
        loc = make_location()
        Location.delete({'id': loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.info({'id': loc['id']})
    def test_positive_delete_by_name(self):
        """Try to delete location using name of that location as a
        parameter. Use different value types for testing.

        @id: b44e56e4-00f0-4b7c-bef6-48b10c7b2b59

        @Assert: Location is deleted successfully

        """
        for name in valid_loc_data_list():
            with self.subTest(name):
                loc = make_location({'name': name})
                self.assertEqual(loc['name'], name)
                Location.delete({'name': loc['name']})
                with self.assertRaises(CLIReturnCodeError):
                    Location.info({'id': loc['id']})
Exemple #5
0
    def test_delete_location_by_name(self):
        """@Test: Try to delete location using name of that location as a
        parameter. Use different value types for testing.

        @Feature: Location

        @Assert: Location is deleted successfully

        """
        for name in valid_data_list():
            with self.subTest(name):
                loc = make_location({'name': name})
                self.assertEqual(loc['name'], name)
                Location.delete({'name': loc['name']})
                with self.assertRaises(CLIReturnCodeError):
                    Location.info({'id': loc['id']})
Exemple #6
0
    def test_delete_location_by_id(self):
        """@Test: Try to delete location using id of that location as a
        parameter

        @Feature: Location

        @Assert: Location is deleted successfully

        """
        loc = make_location()
        result = Location.delete({'id': loc['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Location.info({'id': loc['id']})
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)
Exemple #7
0
    def test_delete_location_by_name(self, name):
        """@Test: Try to delete location using name of that location as a
        parameter. Use different value types for testing.

        @Feature: Location

        @Assert: Location is deleted successfully

        """
        loc = make_location({'name': name})
        self.assertEqual(loc['name'], name)
        result = Location.delete({'name': loc['name']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Location.info({'id': loc['id']})
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)
Exemple #8
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']})
Exemple #9
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']})
Exemple #10
0
 def _cleanup():
     if Location.exists(search=('id', location['id'])):
         Location.delete(options={'id': location['id']})