Ignore:
Timestamp:
14/06/10 11:59:27 (10 years ago)
Author:
pjkersha
Message:

Incomplete - task 9: Data Browser Replacement - Refactoring to include:

  • block based reading and writing of requests/responses
  • Fix to make WSGI compliant input read
  • configurable HTTP method support


Next:

  • URL encoding of file names for GET
  • USe mimetypes package
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ceda_http_fileserver/trunk/ceda_http_fileserver/ceda/server/wsgi/fileserver/test/test_fileserver.py

    r6999 r7009  
    1616from os import path 
    1717 
     18import httplib 
     19 
    1820import paste.fixture 
    1921from paste.deploy import loadapp 
     
    2325 
    2426class FileServerAppTestCase(unittest.TestCase): 
     27    THIS_DIR = path.abspath(path.dirname(__file__)) 
     28    HTDOCS_DIRNAME = 'htdocs' 
     29    HTDOCS_DIR = path.join(THIS_DIR, HTDOCS_DIRNAME) 
     30 
    2531    def __init__(self, *args, **kwargs): 
    26         app = FileServerApp() 
    27         self.app = paste.fixture.TestApp(app) 
     32        self.fileServerApp = FileServerApp(self.__class__.HTDOCS_DIR) 
     33        self.app = paste.fixture.TestApp(self.fileServerApp) 
    2834          
    2935        unittest.TestCase.__init__(self, *args, **kwargs) 
    3036 
    3137    def test01Assert(self): 
    32         # Check the middleware has set the MyProxy client object in environ 
    3338        response = self.app.get('/', status=200) 
     39        print(response) 
    3440        self.assert_(response) 
    3541 
    36     def test01(self): 
    37         pass 
     42    def test02CheckBlkSizeValidation(self): 
     43        def _set(x): 
     44            self.fileServerApp.readBlkSize = x 
     45             
     46        self.assertRaises(ValueError, _set, 'my block size')   
     47        self.assertRaises(ValueError, _set, -10) 
     48         
     49    def test03CheckHttpMethodValidation(self): 
     50        def _set(): 
     51            self.fileServerApp.httpMethodMap = None 
     52             
     53        self.assertRaises(TypeError, _set) 
     54         
     55    def test04TrapHttpMethodNotAllowed(self): 
     56        self.fileServerApp.httpMethodMap = {} 
     57        response = self.app.get('/', status=httplib.METHOD_NOT_ALLOWED) 
    3858     
    3959     
Note: See TracChangeset for help on using the changeset viewer.