summaryrefslogtreecommitdiffstats
path: root/qa/tasks/mgr/dashboard/test_motd.py
blob: 2edbf36ba6a65e494b37b582cb11a20964f6301b (plain)
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
# -*- coding: utf-8 -*-
# pylint: disable=too-many-public-methods

from __future__ import absolute_import

import time

from .helper import DashboardTestCase


class MotdTest(DashboardTestCase):
    @classmethod
    def tearDownClass(cls):
        cls._ceph_cmd(['dashboard', 'motd', 'clear'])
        super(MotdTest, cls).tearDownClass()

    def setUp(self):
        super(MotdTest, self).setUp()
        self._ceph_cmd(['dashboard', 'motd', 'clear'])

    def test_none(self):
        data = self._get('/ui-api/motd')
        self.assertStatus(200)
        self.assertIsNone(data)

    def test_set(self):
        self._ceph_cmd(['dashboard', 'motd', 'set', 'info', '0', 'foo bar baz'])
        data = self._get('/ui-api/motd')
        self.assertStatus(200)
        self.assertIsInstance(data, dict)

    def test_expired(self):
        self._ceph_cmd(['dashboard', 'motd', 'set', 'info', '2s', 'foo bar baz'])
        time.sleep(5)
        data = self._get('/ui-api/motd')
        self.assertStatus(200)
        self.assertIsNone(data)