Changeset 4879


Ignore:
Timestamp:
23 Jan 2010, 08:33:46 (15 years ago)
Author:
uli
Message:

Update tests.

File:
1 edited

Legend:

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

    r4877 r4879  
    4141'.pending'. So, when the input file is named 'foo.csv' and something
    4242went wrong during processing, then a file 'foo.csv.create.pending'
    43 will be generated (if the operation mode was 'create'). The log files
    44 tells why these lines could not be processed.
     43will be generated (if the operation mode was 'create'). The .pending
     44file is a CSV file that contains the failed rows appended by a column
     45``--ERRROR--`` in which the reasons for processing failures are
     46listed.
    4547
    4648It looks like this::
     
    217219    ...                   ['name', 'dinoports', 'owner', 'taxpayer'],
    218220    ...                    mode='create', user='Bob')
    219     (4, {})
     221    (4, 0)
    220222
    221223The result means: four entries were processed and no warnings
     
    257259    Processing time: ... s (... s/item)
    258260    Processed: 4 lines (4 successful/ 0 failed)
    259     ------------------------------------------------------------...
    260261    <BLANKLINE>
    261262
     
    266267    ...                   ['name', 'dinoports', 'owner', 'taxpayer'],
    267268    ...                    mode='create', user='Bob')
    268     (4, {1: 'This object already exists...})
     269    (4, 4)
    269270
    270271The log file will tell us this in more detail:
     
    278279    Processing time: ... s (... s/item)
    279280    Processed: 4 lines (0 successful/ 4 failed)
    280     ----------------------------------------------------------------------
    281     line 1 (1): This object already exists. Skipping.
    282     line 2 (2): This object already exists. Skipping.
    283     line 3 (3): This object already exists. Skipping.
    284     line 4 (4): This object already exists. Skipping.
    285281
    286282This time a new file was created, which keeps all the rows we could not
     
    310306    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    311307    ...                    mode='update', user='Bob')
    312     (4, {})
    313 
    314 No we want to tell, that Wilma got an extra port for her second dino:
     308    (4, 0)
     309
     310Now we want to tell, that Wilma got an extra port for her second dino:
    315311
    316312    >>> open('newcomers.csv', 'wb').write(
     
    327323    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    328324    ...                    mode='update', user='Bob')
    329     (1, {})
     325    (1, 0)
    330326
    331327    >>> wilma = stoneville['Wilmas Asylum']
     
    344340    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    345341    ...                    mode='update', user='Bob')
    346     (1, {1: 'Cannot update: no such entry.'})
     342    (1, 1)
    347343   
    348344Also invalid values will be spotted:
     
    355351    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    356352    ...                    mode='update', user='Bob')
    357     (1, {1: 'conversion error: ... dinoports: ValueError...NOT-A-NUMBER...
     353    (1, 1)
    358354
    359355We can also update only some cols, leaving some out. We skip the
     
    367363    >>> processor.doImport('newcomers.csv', ['name', 'owner'],
    368364    ...                    mode='update', user='Bob')
    369     (1, {})
     365    (1, 0)
    370366
    371367    >>> wilma.owner
     
    398394    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    399395    ...                    mode='update', user='Bob')
    400     (1, {})
     396    (1, 0)
    401397
    402398    >>> wilma.dinoports is None
     
    412408    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    413409    ...                    mode='update', user='Bob')
    414     (1, {})
     410    (1, 0)
    415411
    416412    >>> wilma.dinoports is None
     
    430426    >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'],
    431427    ...                    mode='remove', user='Bob')
    432     (1, {})
     428    (1, 0)
    433429
    434430    >>> sorted(stoneville.keys())
Note: See TracChangeset for help on using the changeset viewer.