source: TI03-DataExtractor/branches/repackaging/server/ndg/dx/server/test/__init__.py @ 1848

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/repackaging/server/ndg/dx/server/test/__init__.py@1848
Revision 1848, 1.4 KB checked in by spascoe, 14 years ago (diff)

Script hook into the test_suite.

RevLine 
[1815]1"""
2Unit tests for the data extractor server.
3
4@author: Stephen Pascoe
5"""
6
[1840]7import sys, os, pkg_resources, tempfile, shutil
[1844]8import unittest, re
[1815]9
[1840]10from ndg.dx.server.MakeConfig import makeConfig
11
[1815]12class TestCase(unittest.TestCase):
[1840]13    """
14    These tests assume you have a NDG_HOME directory pre-configured.
15    """
16
[1815]17    def setUp(self):
[1840]18        # Create the NDG_HOME/dxs directory if it doesn't exist
19        makeConfig()
[1844]20        from ndg.dx.server.scripts import DXWSInterface
21        self.DXWSInterface = DXWSInterface
[1815]22
23    def testStartSession(self):
[1844]24        (session, secureToken) = self.DXWSInterface.startSession('rob', 'rob1')
25        self.assert_(re.match(r'session_', session))
26        self.assert_(secureToken == 'undefined')
27       
28    def testGetOptions(self):
29        (session, secureToken) = self.DXWSInterface.startSession('rob', 'rob1')
30        self.DXWSInterface.getOptions(session, secureToken)
[1815]31
32test_suite = unittest.TestSuite()
33test_suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestCase))
[1848]34
35def main(args=None):
36    """Script entry point that runs test_case.
37    """
38    if not args:
39        args = sys.argv[1:]
40
41    if args:
42        (test_home,) = args
43    else:
44        test_home = './test_home'
45
46    from ndg.dx.server.MakeConfig import makeTestHome
47    makeTestHome(test_home)
48       
49    tr = unittest.TextTestRunner()
50    tr.run(test_suite)
51
52if __name__ == '__main__':
53    main()
Note: See TracBrowser for help on using the repository browser.