File: test_messages.py

package info (click to toggle)
python-manilaclient 5.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,768 kB
  • sloc: python: 49,541; makefile: 99; sh: 2
file content (70 lines) | stat: -rw-r--r-- 2,755 bytes parent folder | download | duplicates (3)
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
#    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.

import ddt

from manilaclient.tests.functional import base


@ddt.ddt
class MessagesReadOnlyTest(base.BaseTestCase):

    @ddt.data(
        ("admin", "2.37"),
        ("user", "2.37"),
    )
    @ddt.unpack
    def test_message_list(self, role, microversion):
        self.skip_if_microversion_not_supported(microversion)
        self.clients[role].manila("message-list", microversion=microversion)


@ddt.ddt
class MessagesReadWriteTest(base.BaseTestCase):

    def setUp(self):
        super(MessagesReadWriteTest, self).setUp()
        self.message = self.create_message()

    def test_list_messages(self):
        self.skip_if_microversion_not_supported('2.37')
        messages = self.admin_client.list_messages()
        self.assertTrue(any(m['ID'] is not None for m in messages))
        self.assertTrue(any(m['User Message'] is not None for m in messages))
        self.assertTrue(any(m['Resource ID'] is not None for m in messages))
        self.assertTrue(any(m['Action ID'] is not None for m in messages))
        self.assertTrue(any(m['Detail ID'] is not None for m in messages))
        self.assertTrue(any(m['Resource Type'] is not None for m in messages))

    @ddt.data(
        'id', 'action_id', 'resource_id', 'action_id', 'detail_id',
        'resource_type', 'created_at', 'action_id,detail_id,resource_id',
    )
    def test_list_share_type_select_column(self, columns):
        self.skip_if_microversion_not_supported('2.37')
        self.admin_client.list_messages(columns=columns)

    def test_get_message(self):
        self.skip_if_microversion_not_supported('2.37')
        message = self.admin_client.get_message(self.message['ID'])
        expected_keys = (
            'id', 'action_id', 'resource_id', 'action_id', 'detail_id',
            'resource_type', 'created_at', 'created_at',
        )
        for key in expected_keys:
            self.assertIn(key, message)

    def test_delete_message(self):
        self.skip_if_microversion_not_supported('2.37')
        message = self.create_message(cleanup_in_class=False)
        self.admin_client.delete_message(message['ID'])
        self.admin_client.wait_for_message_deletion(message['ID'])