Changeset 4871 for waeup/trunk


Ignore:
Timestamp:
21 Jan 2010, 14:57:03 (15 years ago)
Author:
uli
Message:

Update tests to check for format of values in pending files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/trunk/src/waeup/utils/batching.txt

    r4858 r4871  
    9393    ...     required = True,
    9494    ...     missing_value = 'Fred Estates Inc.')
     95    ...   taxpayer = schema.Bool(
     96    ...     title = u'Payes taxes',
     97    ...     required = True,
     98    ...     default = False)
    9599
    96100Now a class that implements this interface:
     
    100104    ...   grok.implements(ICave)
    101105    ...   def __init__(self, name=u'Unnamed', dinoports=2,
    102     ...                owner='Fred Estates Inc.'):
     106    ...                owner='Fred Estates Inc.', taxpayer=False):
    103107    ...     self.name = name
    104108    ...     self.dinoports = 2
    105109    ...     self.owner = owner
     110    ...     self.taxpayer = taxpayer
    106111
    107112We also provide a factory for caves. Strictly speaking, this not
     
    164169
    165170    >>> open('newcomers.csv', 'wb').write(
    166     ... """name,dinoports,owner
    167     ... Barneys Home,2,Barney
    168     ... Wilmas Asylum,1,Wilma
    169     ... Freds Dinoburgers,10,Fred
    170     ... Joeys Drive-in,110,Joey
     171    ... """name,dinoports,owner,taxpayer
     172    ... Barneys Home,2,Barney,1
     173    ... Wilmas Asylum,1,Wilma,1
     174    ... Freds Dinoburgers,10,Fred,0
     175    ... Joeys Drive-in,110,Joey,0
    171176    ... """)
    172177
     
    209214
    210215    >>> processor = CaveProcessor()
    211     >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
     216    >>> processor.doImport('newcomers.csv',
     217    ...                   ['name', 'dinoports', 'owner', 'taxpayer'],
    212218    ...                    mode='create', user='Bob')
    213219    (4, {})
     
    257263could be read here as we can see, if we do the same operation again:
    258264
    259     >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
     265    >>> processor.doImport('newcomers.csv',
     266    ...                   ['name', 'dinoports', 'owner', 'taxpayer'],
    260267    ...                    mode='create', user='Bob')
    261268    (4, {1: 'This object already exists...})
     
    281288
    282289    >>> print open('newcomers.csv.create.pending').read()
    283     owner,name,dinoports
    284     Barney,Barneys Home,2
    285     Wilma,Wilmas Asylum,1
    286     Fred,Freds Dinoburgers,10
    287     Joey,Joeys Drive-in,110
     290    owner,name,taxpayer,dinoports
     291    Barney,Barneys Home,1,2
     292    Wilma,Wilmas Asylum,1,1
     293    Fred,Freds Dinoburgers,0,10
     294    Joey,Joeys Drive-in,0,110
    288295
    289296This way we can correct the faulty entries and afterwards retry without
    290297having the already processed rows in the way.
     298
     299We also notice, that the values of the taxpayer column are returned as
     300in the input file. There we wrote '1' for ``True`` and '0' for
     301``False`` (which is accepted by the converters).
    291302
    292303
Note: See TracChangeset for help on using the changeset viewer.