source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/__init__.py @ 5499

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/__init__.py@5499
Revision 5499, 1.4 KB checked in by pjkersha, 11 years ago (diff)
  • Added IdP ValidationDriver? specialisation for SSL peer cert verification using M2Crypto
  • completed tests for OpenID Relying Party IdP validation - ndg.security.test.unit.openid.relyingparty.validation
Line 
1"""NDG Security unit test package
2
3NERC Data Grid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "14/05/09"
7__copyright__ = "(C) 2009 Science and Technology Facilities Council"
8__license__ = "BSD - see LICENSE file in top-level directory"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__revision__ = '$Id: __init__.py 4840 2009-01-19 13:59:08Z pjkersha $'
11
12import unittest
13import logging
14logging.basicConfig()
15
16import os
17from os.path import expandvars, join, dirname, abspath
18
19TEST_CONFIG_DIR = join(abspath(dirname(dirname(__file__))), 'config')
20
21class BaseTestCase(unittest.TestCase):
22    '''Convenience base class from which other unit tests can extend.  Its
23    sets the generic data directory path'''
24    configDirEnvVarName = 'NDGSEC_TEST_CONFIG_DIR'
25   
26    def __init__(self, *arg, **kw):
27        if BaseTestCase.configDirEnvVarName not in os.environ:
28            os.environ[BaseTestCase.configDirEnvVarName] = TEST_CONFIG_DIR
29               
30        unittest.TestCase.__init__(self, *arg, **kw)
31
32mkDataDirPath = lambda file:join(TEST_CONFIG_DIR, file)
33
34def _getParentDir(depth=0, path=dirname(__file__)):
35    """
36    @type path: basestring
37    @param path: directory path from which to get parent directory, defaults
38    to dir of this module
39    @rtype: basestring
40    @return: parent directory at depth levels up from the current path
41    """
42    for i in range(depth):
43        path = dirname(path)
44    return path
45
46
Note: See TracBrowser for help on using the repository browser.