Changeset 5127


Ignore:
Timestamp:
5 Apr 2010, 13:44:44 (15 years ago)
Author:
uli
Message:
  • Reorder statements in PIN generation to get better test-coverage.
  • Add createBatch method for batch containers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py

    r5123 r5127  
    9595            for x in range(10):
    9696                pin += str(random().randint(0, 9))
    97             if '%s-%s-%s' % (self.prefix, self.num, pin) in self._acids:
    98                 # PIN already in use
    99                 continue
    100             curr += 1
    101             yield pin
     97            if not '%s-%s-%s' % (self.prefix, self.num, pin) in self._acids:
     98                curr += 1
     99                yield pin
     100            # PIN already in use
    102101
    103102    def _getStoragePath(self):
     
    207206        self._p_changed = True
    208207
     208    def createBatch(self, creation_date, creator, batch_prefix, cost,
     209                    entry_num):
     210        """Create and add a batch.
     211        """
     212        batch_num = self.getNum(batch_prefix)
     213        batch = AccessCodeBatch(creation_date, creator, batch_prefix,
     214                                cost, entry_num, num=batch_num)
     215        self.addBatch(batch)
     216        return batch
     217       
    209218    def getNum(self, prefix):
    210219        """Get next unused num for given prefix.
Note: See TracChangeset for help on using the changeset viewer.