Show More
@@ -1,78 +1,84 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2016 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | import pytest |
|
22 | import pytest | |
23 |
|
23 | |||
24 | from rhodecode.model.scm import ScmModel |
|
24 | from rhodecode.model.scm import ScmModel | |
25 | from rhodecode.api.tests.utils import build_data, api_call, assert_ok |
|
25 | from rhodecode.api.tests.utils import build_data, api_call, assert_ok | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | @pytest.fixture |
|
28 | @pytest.fixture | |
29 | def http_host_stub(): |
|
29 | def http_host_stub(): | |
30 | """ |
|
30 | """ | |
31 | To ensure that we can get an IP address, this test shall run with a |
|
31 | To ensure that we can get an IP address, this test shall run with a | |
32 | hostname set to "localhost". |
|
32 | hostname set to "localhost". | |
33 | """ |
|
33 | """ | |
34 | return 'localhost:80' |
|
34 | return 'localhost:80' | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | @pytest.mark.usefixtures("testuser_api", "app") |
|
37 | @pytest.mark.usefixtures("testuser_api", "app") | |
38 | class TestGetServerInfo(object): |
|
38 | class TestGetServerInfo(object): | |
39 | def test_api_get_server_info(self): |
|
39 | def test_api_get_server_info(self): | |
40 | id_, params = build_data(self.apikey, 'get_server_info') |
|
40 | id_, params = build_data(self.apikey, 'get_server_info') | |
41 | response = api_call(self.app, params) |
|
41 | response = api_call(self.app, params) | |
42 | resp = response.json |
|
42 | resp = response.json | |
43 | expected = ScmModel().get_server_info() |
|
43 | expected = ScmModel().get_server_info() | |
44 | expected['memory'] = resp['result']['memory'] |
|
44 | expected['memory'] = resp['result']['memory'] | |
45 | expected['uptime'] = resp['result']['uptime'] |
|
45 | expected['uptime'] = resp['result']['uptime'] | |
46 | expected['load'] = resp['result']['load'] |
|
46 | expected['load'] = resp['result']['load'] | |
47 | expected['cpu'] = resp['result']['cpu'] |
|
47 | expected['cpu'] = resp['result']['cpu'] | |
48 | expected['storage'] = resp['result']['storage'] |
|
48 | expected['storage'] = resp['result']['storage'] | |
49 | expected['storage_temp'] = resp['result']['storage_temp'] |
|
49 | expected['storage_temp'] = resp['result']['storage_temp'] | |
50 | expected['storage_inodes'] = resp['result']['storage_inodes'] |
|
50 | expected['storage_inodes'] = resp['result']['storage_inodes'] | |
51 | expected['server'] = resp['result']['server'] |
|
51 | expected['server'] = resp['result']['server'] | |
52 |
|
52 | |||
|
53 | expected['index_storage'] = resp['result']['index_storage'] | |||
|
54 | expected['storage'] = resp['result']['storage'] | |||
|
55 | ||||
53 | assert_ok(id_, expected, given=response.body) |
|
56 | assert_ok(id_, expected, given=response.body) | |
54 |
|
57 | |||
55 | def test_api_get_server_info_ip(self): |
|
58 | def test_api_get_server_info_ip(self): | |
56 | id_, params = build_data(self.apikey, 'get_server_info') |
|
59 | id_, params = build_data(self.apikey, 'get_server_info') | |
57 | response = api_call(self.app, params) |
|
60 | response = api_call(self.app, params) | |
58 | resp = response.json |
|
61 | resp = response.json | |
59 | expected = ScmModel().get_server_info({'SERVER_NAME': 'unknown'}) |
|
62 | expected = ScmModel().get_server_info({'SERVER_NAME': 'unknown'}) | |
60 | expected['memory'] = resp['result']['memory'] |
|
63 | expected['memory'] = resp['result']['memory'] | |
61 | expected['uptime'] = resp['result']['uptime'] |
|
64 | expected['uptime'] = resp['result']['uptime'] | |
62 | expected['load'] = resp['result']['load'] |
|
65 | expected['load'] = resp['result']['load'] | |
63 | expected['cpu'] = resp['result']['cpu'] |
|
66 | expected['cpu'] = resp['result']['cpu'] | |
64 | expected['storage'] = resp['result']['storage'] |
|
67 | expected['storage'] = resp['result']['storage'] | |
65 | expected['storage_temp'] = resp['result']['storage_temp'] |
|
68 | expected['storage_temp'] = resp['result']['storage_temp'] | |
66 | expected['storage_inodes'] = resp['result']['storage_inodes'] |
|
69 | expected['storage_inodes'] = resp['result']['storage_inodes'] | |
67 | expected['server'] = resp['result']['server'] |
|
70 | expected['server'] = resp['result']['server'] | |
68 |
|
71 | |||
|
72 | expected['index_storage'] = resp['result']['index_storage'] | |||
|
73 | expected['storage'] = resp['result']['storage'] | |||
|
74 | ||||
69 | assert_ok(id_, expected, given=response.body) |
|
75 | assert_ok(id_, expected, given=response.body) | |
70 |
|
76 | |||
71 | def test_api_get_server_info_data_for_search_index_build(self): |
|
77 | def test_api_get_server_info_data_for_search_index_build(self): | |
72 | id_, params = build_data(self.apikey, 'get_server_info') |
|
78 | id_, params = build_data(self.apikey, 'get_server_info') | |
73 | response = api_call(self.app, params) |
|
79 | response = api_call(self.app, params) | |
74 | resp = response.json |
|
80 | resp = response.json | |
75 |
|
81 | |||
76 | # required by indexer |
|
82 | # required by indexer | |
77 | assert resp['result']['index_storage'] |
|
83 | assert resp['result']['index_storage'] | |
78 | assert resp['result']['storage'] |
|
84 | assert resp['result']['storage'] |
General Comments 0
You need to be logged in to leave comments.
Login now