Changeset 4174 for waeup


Ignore:
Timestamp:
26 May 2009, 20:08:01 (16 years ago)
Author:
uli
Message:

Update datacenter tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/datacenter.txt

    r4172 r4174  
    2323
    2424
     25Managing the storage path
     26-------------------------
     27
     28We can set another storage path:
     29
     30    >>> import os
     31    >>> os.mkdir('newlocation')
     32    >>> newpath = os.path.abspath('newlocation')
     33    >>> mydatacenter.setStoragePath(newpath)
     34
     35When we set a new storage path, we can tell to move all files in the
     36old location to the new one. To see this feature in action, we first
     37have to put a file into the old location:
     38
     39    >>> open(os.path.join(newpath, 'myfile.txt'), 'wb').write('hello')
     40
     41Now we can set a new location and the file will be copied:
     42
     43    >>> verynewpath = os.path.abspath('verynewlocation')
     44    >>> os.mkdir(verynewpath)
     45
     46    >>> mydatacenter.setStoragePath(verynewpath, move=True)
     47    >>> storagepath = mydatacenter.storage
     48    >>> 'myfile.txt' in os.listdir(verynewpath)
     49    True
     50
     51We remove the created file to have a clean testing environment for
     52upcoming examples:
     53
     54    >>> os.unlink(os.path.join(storagepath, 'myfile.txt'))
     55
    2556Uploading files
    2657===============
     
    5687Clean up:
    5788
    58     >>> os.unlink(filepath)
     89    >>> import shutil
     90    >>> shutil.rmtree(newpath)
     91    >>> shutil.rmtree(verynewpath)
    5992
    6093
     
    166199
    167200As we can see, an import is defined here as a tuple of a
    168 DataCenterFile and a list of available importers.
     201DataCenterFile and a list of available importers with an associated
     202data receiver (the thing where the data should go to).
    169203
    170204Clean up:
Note: See TracChangeset for help on using the changeset viewer.