5417ad95323932a37a641efe6cf00958a00b3ad9
[yardstick.git] / tests / unit / apiserver / resources / test_env_action.py
1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
10
11 import time
12 import unittest
13
14 from tests.unit.apiserver import APITestCase
15
16
17 class EnvTestCase(APITestCase):
18
19     def test_create_grafana(self):
20         if self.app is None:
21             unittest.skip('host config error')
22             return
23
24         url = 'yardstick/env/action'
25         data = {'action': 'create_grafana'}
26         resp = self._post(url, data)
27
28         time.sleep(0)
29
30         task_id = resp['result']['task_id']
31         url = '/yardstick/asynctask?task_id={}'.format(task_id)
32         resp = self._get(url)
33
34         time.sleep(0)
35
36         self.assertTrue(u'status' in resp)
37
38
39 def main():
40     unittest.main()
41
42
43 if __name__ == '__main__':
44     main()