Ignore:
Timestamp:
2 Apr 2009, 11:39:53 (16 years ago)
Author:
uli
Message:

Add tests.

File:
1 edited

Legend:

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

    r4048 r4051  
    7676    >>> import os
    7777    >>> os.unlink('myexport.xml')
     78
     79Importing XML
     80=============
     81
     82We can generate objects from XML.
     83
     84Let's create a faculty instance, that we want to be restored
     85afterwards::
     86
     87    >>> from waeup.university.faculty import Faculty
     88    >>> myfaculty = Faculty()
     89    >>> myfaculty.name = 'My very faculty.'
     90
     91We create an XML dump of this object::
     92
     93    >>> from waeup.interfaces import IWAeUPXMLExporter
     94    >>> exporter = IWAeUPXMLExporter(myfaculty)
     95    >>> result = exporter.export('myexport.xml')
     96
     97We change the name of the faculty::
     98
     99    >>> myfaculty.name = 'Another name'
     100
     101Now we create an importer for that file::
     102
     103    >>> from waeup.interfaces import IWAeUPXMLImporter
     104    >>> importer = IWAeUPXMLImporter(myfaculty)
     105    >>> new_obj = importer.doImport('myexport.xml')
     106
     107The object created is indeed a faculty::
     108
     109    >>> new_obj
     110    <waeup.university.faculty.Faculty object at 0x...>
     111
     112    >>> new_obj.name
     113    'My very faculty'
Note: See TracChangeset for help on using the changeset viewer.