Changeset 1186

Show
Ignore:
Timestamp:
09/26/08 23:01:57 (8 weeks ago)
Author:
gawel
Message:

fix tests

Location:
gp.fileupload/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • gp.fileupload/trunk/gp/fileupload/tests.py

    r1165 r1186  
    7 7 import doctest 
    8 8 from StringIO import StringIO 
      9 from nose import with_setup 
    9 10 import gp.fileupload 
    10 11 from gp.fileupload.config import * 
    … …  
    45 46         return [environ['test_path']] 
    46 47  
    47       data = [l for l in environ['wsgi.input']] 
      48     data = [l for l in environ['wsgi.input'].readlines()] 
    48 49     if len(data) > 0: 
    49 50         start_response('200 OK', [('Content-Type', 'text/plain;charset=utf-8')]) 
    … …  
    71 72 ''' % (BOUNDARY, BOUNDARY, BOUNDARY) 
    72 73 TEST_LENGTH = str(len(TEST_DATA)) 
      74  
      75 def setup_func(): 
      76     if os.path.isdir(TEMP_DIR): 
      77         shutil.rmtree(TEMP_DIR) 
      78     os.mkdir(TEMP_DIR) 
      79  
      80 def teardown_func(): 
      81     shutil.rmtree(TEMP_DIR) 
    73 82  
    74 83 def test_injection(): 
    … …  
    80 89     assert '/gp.fileupload.static/fileupload.css' in output, output 
    81 90  
      91 @with_setup(setup_func, teardown_func) 
    82 92 def test_static_content(): 
    83 93     app = validator(FileUpload(application)) 
    … …  
    87 97     assert output.startswith('.fuProgress'), output 
    88 98  
      99 @with_setup(setup_func, teardown_func) 
    89 100 def test_stat(): 
    90 101     app = validator(FileUpload(application)) 
    … …  
    94 105     assert output == "{'state': 0, 'percent': 0}", output 
    95 106  
      107 @with_setup(setup_func, teardown_func) 
    96 108 def test_upload(): 
    97 109     shutil.rmtree(TEMP_DIR) 
    … …  
    103 115     environ.update({'PATH_INFO':'/', 'QUERY_STRING':'gp.fileupload.id=1', 
    104 116                     'CONTENT_LENGTH':TEST_LENGTH, 
      117                     'REQUEST_METHOD':'POST', 
    105 118                     'wsgi.input': StringIO(TEST_DATA)}) 
    106 119     output = get_output(app(environ, fake_start_response)) 
    … …  
    111 124     environ.update({'PATH_INFO':'/gp.fileupload.stat/1'}) 
    112 125     output = get_output(app(environ, fake_start_response)) 
    113       # FIXME 
    114       #assert output == "{'state': 1, 'percent': 100}", output 
      126     assert output == "{'state': 1, 'percent': 100}", output 
    115 127  
    116 128     # check temp files 
    … …  
    118 130     assert len(tempfiles) == 0, tempfiles 
    119 131  
      132 @with_setup(setup_func, teardown_func) 
    120 133 def test_storage(): 
    121       shutil.rmtree(TEMP_DIR) 
    122 134  
    123 135     app = validator(Storage(application, TEMP_DIR, exclude_paths=['/@@'])) 
    … …  
    164 176     assert len(tempfiles) == 0, tempfiles 
    165 177  
    166       # rm TEMP_DIR 
    167       shutil.rmtree(TEMP_DIR) 
    168 178  
    169 179 ############### 
    … …  
    196 206             """init globals 
    197 207             """ 
      208             setup_func() 
    198 209             test = self._dt_test 
    199 210  
    … …  
    203 214             test = self._dt_test 
    204 215             test.globs.clear() 
      216             teardown_func() 
    205 217  
    206 218     # generate a new class for the file 
  • gp.fileupload/trunk/gp/fileupload/upload.py

    r1145 r1186  
    166 166             else: 
    167 167                 # return progress 
    168                   #size = os.stat(tempfile)[stat.ST_SIZE] 
    169 168                 try: 
    170 169                     size = int(open(tempfile).read()) 
  • gp.fileupload/trunk/setup.cfg

    r940 r1186  
    2 2 tag_build = dev 
    3 3 tag_svn_revision = true 
      4  
      5 [nosetests] 
      6 verbosity=3