Package omeroweb :: Package webadmin :: Package tests :: Module webadmin_test_library
[hide private]
[frames] | no frames]

Source Code for Module omeroweb.webadmin.tests.webadmin_test_library

 1  #!/usr/bin/env python 
 2  #  
 3  #  
 4  # Copyright (c) 2008 University of Dundee.  
 5  #  
 6  # This program is free software: you can redistribute it and/or modify 
 7  # it under the terms of the GNU Affero General Public License as 
 8  # published by the Free Software Foundation, either version 3 of the 
 9  # License, or (at your option) any later version. 
10  #  
11  # This program is distributed in the hope that it will be useful, 
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  # GNU Affero General Public License for more details. 
15  #  
16  # You should have received a copy of the GNU Affero General Public License 
17  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
18  # 
19   
20  import os 
21  import unittest 
22  import exceptions 
23   
24  import omero 
25   
26  from django.conf import settings 
27  from request_factory import Client 
28   
29  from omeroweb.webgateway import views as webgateway_views 
30   
31 -class WebTest(unittest.TestCase):
32
33 - def setUp (self):
34 c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))]) 35 try: 36 self.root_password = c.ic.getProperties().getProperty('omero.rootpass') 37 omero_host = c.ic.getProperties().getProperty('omero.host') 38 finally: 39 c.__del__() 40 41 blitz = settings.SERVER_LIST.find(server_host=omero_host) 42 if blitz is not None: 43 self.server_id = blitz.id 44 self.rootconn = webgateway_views._createConnection('', host=blitz.host, port=blitz.port, username='root', passwd=self.root_password, secure=True, useragent="TEST.webadmin") 45 if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive(): 46 raise exceptions.Exception("Cannot connect") 47 else: 48 raise exceptions.Exception("'%s' is not on omero.web.server_list")
49
50 - def tearDown(self):
51 try: 52 self.rootconn.seppuku() 53 except Exception,e: 54 self.fail(e)
55
56 - def loginAsUser(self, username, password):
57 blitz = settings.SERVER_LIST.get(pk=self.server_id) 58 if blitz is not None: 59 conn = webgateway_views._createConnection('', host=blitz.host, port=blitz.port, username=username, passwd=password, secure=True, useragent="TEST.webadmin") 60 if conn is None or not conn.isConnected() or not conn.keepAlive(): 61 raise exceptions.Exception("Cannot connect") 62 return conn 63 else: 64 raise exceptions.Exception("'%s' is not on omero.web.server_list")
65
66 -class WebAdminClientTest(WebTest):
67
68 - def setUp (self):
69 super(WebAdminClientTest, self).setUp() 70 self.client = Client()
71
72 - def tearDown(self):
73 try: 74 self.client.logout() 75 except Exception,e: 76 self.fail(e)
77