~coreygoldberg/uci-engine/subunit-results

« back to all changes in this revision

Viewing changes to tests/test_webui.py

Merge trunk, resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Ubuntu Continuous Integration Engine
 
3
# Copyright 2014 Canonical Ltd.
 
4
 
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU Affero General Public License version 3, as
 
7
# published by the Free Software Foundation.
 
8
 
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU Affero General Public License for more details.
 
13
 
 
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/>.
 
16
import json
 
17
import httplib2
 
18
import unittest
 
19
import deployers
 
20
 
 
21
 
 
22
class WebUITest(deployers.DeployerTest):
 
23
    """Integration tests for ticket-system service run on a juju deployment"""
 
24
 
 
25
    def get_server_status_and_content(self, url):
 
26
        final_url = url.format(
 
27
            self.get_ip_and_port('ci-airline-webui-apache')[0])
 
28
 
 
29
        # Issue a simple command against the ticket API
 
30
        client = httplib2.Http()
 
31
        return client.request(final_url, 'GET')
 
32
 
 
33
    def test_index(self):
 
34
        '''show we can load our front page.'''
 
35
        url = 'http://{}/'
 
36
        self.get_ip_and_port('ci-airline-webui-apache')
 
37
        resp, content = self.get_server_status_and_content(url)
 
38
        self.assertEqual('200', resp['status'])
 
39
 
 
40
    def test_json_status(self):
 
41
        '''Ensure the webui charm is providing us a valid status_urls.json'''
 
42
        url = 'http://{}/static/engine-health/status_urls.json'
 
43
        self.get_ip_and_port('ci-airline-webui-apache')
 
44
        resp, content = self.get_server_status_and_content(url)
 
45
        self.assertEqual('200', resp['status'])
 
46
        json.loads(content)
 
47
 
 
48
    def test_status_page(self):
 
49
        '''show we can load our front page.'''
 
50
        url = 'http://{}/status/'
 
51
        self.get_ip_and_port('ci-airline-webui-apache')
 
52
        resp, content = self.get_server_status_and_content(url)
 
53
        self.assertEqual('200', resp['status'])
 
54
        self.assertIn('href="/status/" class="active">Engine health', content)
 
55
 
 
56
 
 
57
if __name__ == "__main__":
 
58
    unittest.main()