configurationengine/source/cone/storage/tests/unittest_fileresource.py
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
equal deleted inserted replaced
2:87cfa131b535 3:e7e0ae78773e
    17 
    17 
    18 """
    18 """
    19 Test the CPF root file parsing routines
    19 Test the CPF root file parsing routines
    20 """
    20 """
    21 
    21 
    22 import zipfile
       
    23 import unittest
    22 import unittest
    24 import string
    23 import os
    25 import sys,os
       
    26 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
    24 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
    27 
    25 
    28 import __init__
    26 from cone.public.exceptions import StorageException
    29 from cone.public.exceptions import NotResource, StorageException
       
    30 from cone.public import api
    27 from cone.public import api
    31 from cone.storage import filestorage
    28 from cone.storage import filestorage
    32 
    29 
    33 
    30 
    34 class TestFileResource(unittest.TestCase):    
    31 class TestFileResource(unittest.TestCase):    
   149         self.assertEquals('image', content_info.mimetype)
   146         self.assertEquals('image', content_info.mimetype)
   150         self.assertEquals('bmp', content_info.mimesubtype)
   147         self.assertEquals('bmp', content_info.mimesubtype)
   151         res.close()
   148         res.close()
   152         
   149         
   153     def test_get_content_info_and_read_data(self):
   150     def test_get_content_info_and_read_data(self):
   154         res = self.storage.open_resource("testread.txt", "r")
   151         res = self.storage.open_resource("testread.txt", "rb")
   155         ci = res.get_content_info()
   152         ci = res.get_content_info()
   156         self.assertEquals('text/plain', ci.content_type)
   153         self.assertEquals('text/plain', ci.content_type)
   157         data = res.read()
   154         data = res.read()
   158         self.assertEquals('foo bar test.\n', data)
   155         self.assertEquals('foo bar test.\r\n', data)
   159         res.close()
   156         res.close()
   160         
   157         
   161 if __name__ == '__main__':
   158 if __name__ == '__main__':
   162       unittest.main()
   159     unittest.main()