source: mauRepo/HPFos/trunk/hpfos/tests/testsetup.py @ 8523

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/HPFos/trunk/hpfos/tests/testsetup.py@8523
Revision 8523, 1.4 KB checked in by mnagni, 9 years ago (diff)

Requests, parse and display a fatcat atom feed

Line 
1from unittest import TestCase
2from hpfos.tests.testconfig import MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, EVENTS_DB
3from hpfos.libs.commons_db import DbManager
4from hpfos.HPFos.moles3epb import Moles3EPBFactory
5from hpfos.HPFos.osImpl.hpfos_conf import setUp
6from django.test.client import RequestFactory
7
8
9
10class HPFosTest(TestCase):
11    '''
12    Exploits tests mainly over MO_ResponsiblePartyInfo instances.
13    '''
14    initialized = False
15    epbRepo = None
16    osEngine = None
17    reqFactory = None
18   
19    def setUp(self):
20        if not HPFosTest.initialized:
21            molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, sql_echo=True, session_event_manager=EVENTS_DB)                                             
22            moles3Factory = Moles3EPBFactory(molesDB)
23            HPFosTest.epbRepo = moles3Factory.createEPB()
24            HPFosTest.initialized = True
25                           
26        self.epbRepo = HPFosTest.epbRepo
27        self.os_engine = setUp()
28        environ = {
29            'SERVER_NAME': 'fatcat.badc.rl.ac.uk',
30        }
31        self.reqFactory = MyRequest(**environ)       
32
33    def tearDown(self):
34        pass
35
36class MyRequest(RequestFactory):
37   
38    def __init__(self, secure = False, **defaults):
39        self.secure = secure
40        super(MyRequest, self).__init__(**defaults)
41
42    def get_host(self):
43        return getattr(self, 'environ')['SERVER_NAME']
44
45    def is_secure(self):
46        return getattr(self, 'host')
Note: See TracBrowser for help on using the repository browser.