File: test_service_profile.py

package info (click to toggle)
python-openstacksdk 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,352 kB
  • sloc: python: 122,960; sh: 153; makefile: 23
file content (94 lines) | stat: -rw-r--r-- 3,484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from openstack.network.v2 import service_profile as _service_profile
from openstack.tests.functional import base


class TestServiceProfile(base.BaseFunctionalTest):
    SERVICE_PROFILE_DESCRIPTION = "DESCRIPTION"
    UPDATE_DESCRIPTION = "UPDATED-DESCRIPTION"
    METAINFO = "FlAVOR_PROFILE_METAINFO"
    ID = None

    def setUp(self):
        super().setUp()
        if not self.user_cloud._has_neutron_extension("flavors"):
            self.skipTest("Neutron flavor extension is required for this test")

        if self.operator_cloud:
            service_profiles = (
                self.operator_cloud.network.create_service_profile(
                    description=self.SERVICE_PROFILE_DESCRIPTION,
                    metainfo=self.METAINFO,
                )
            )
            assert isinstance(
                service_profiles, _service_profile.ServiceProfile
            )
            self.assertEqual(
                self.SERVICE_PROFILE_DESCRIPTION, service_profiles.description
            )
            self.assertEqual(self.METAINFO, service_profiles.meta_info)

            self.ID = service_profiles.id

    def tearDown(self):
        if self.ID:
            service_profiles = (
                self.operator_cloud.network.delete_service_profile(
                    self.ID, ignore_missing=True
                )
            )
            self.assertIsNone(service_profiles)
        super().tearDown()

    def test_find(self):
        self.user_cloud.network.find_service_profile(
            name_or_id="not_existing", ignore_missing=True
        )
        if self.operator_cloud and self.ID:
            service_profiles = (
                self.operator_cloud.network.find_service_profile(self.ID)
            )
            self.assertEqual(self.METAINFO, service_profiles.meta_info)

    def test_get(self):
        if not self.ID:
            self.skipTest("ServiceProfile was not created")
        service_profiles = self.operator_cloud.network.get_service_profile(
            self.ID
        )
        self.assertEqual(self.METAINFO, service_profiles.meta_info)
        self.assertEqual(
            self.SERVICE_PROFILE_DESCRIPTION, service_profiles.description
        )

    def test_update(self):
        if not self.ID:
            self.skipTest("ServiceProfile was not created")
        service_profiles = self.operator_cloud.network.update_service_profile(
            self.ID, description=self.UPDATE_DESCRIPTION
        )
        self.assertEqual(self.UPDATE_DESCRIPTION, service_profiles.description)

    def test_list(self):
        # Test in user scope
        self.user_cloud.network.service_profiles()
        # Test as operator
        if self.operator_cloud:
            metainfos = [
                f.meta_info
                for f in self.operator_cloud.network.service_profiles()
            ]
            if self.ID:
                self.assertIn(self.METAINFO, metainfos)