Ignore:
Timestamp:
16 Oct 2012, 09:42:18 (12 years ago)
Author:
uli
Message:

Move fake job components to a more general location.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/testing.py

    r9289 r9342  
    2929import zope.component
    3030import waeup.kofa
     31from zc.async.interfaces import COMPLETED
    3132from zope.app.testing.functional import (
    3233    ZCMLLayer, FunctionalTestSetup, getRootFolder, sync, FunctionalTestCase)
     
    430431        suite.addTest(test)
    431432    return suite
     433
     434class FakeJob(object):
     435    # A job usable for simple async tests
     436    status = COMPLETED
     437    result = None
     438
     439class FakeJobManager(object):
     440    # A fake job manager for testing async functionality
     441    _jobs = dict()
     442    _curr_num = 1
     443
     444    def get(self, job_id):
     445        if job_id == '3':
     446            return FakeJob()
     447        return self._jobs.get(job_id, None)
     448
     449    def put(self, job):
     450        num = str(self._curr_num)
     451        self._jobs[num] = job
     452        self._curr_num += 1
     453        return num
     454
     455    def remove(self, job_id, site):
     456        if job_id in self._jobs:
     457            del self._jobs[job_id]
     458        return
Note: See TracChangeset for help on using the changeset viewer.