I'm trying to add some test infrastructure to the scheduling code in
TracPM (part of the trac-jsGantt plugin) and I'm running into an
issue.
tracpm.py includes:
-------------------------------
class ResourceScheduler(Component):
implements(ITaskScheduler)
...
-------------------------------
and
-------------------------------
class TracPM(Component):
implements(IEnvironmentSetupParticipant)
...
# IEnvironmentSetupParticipant methods
def environment_created(self):
...
def environment_needs_upgrade(self, db):
...
def upgrade_environment(self, db):
...
# Configurable data sources
fields = None
...
Option(cfgSection, 'hours_per_estimate', '1',
"""Hours represented by each unit of estimated work""")
...
scheduler = ExtensionOption(cfgSection, 'scheduler',
ITaskScheduler, 'ResourceScheduler')
def __init__(self):
-------------------------------
and my test script sets up an environment, creates an instance of
TracPM using that environment, then
-------------------------------
pm.recomputeSchedule(options, tickets)
-------------------------------
and I get:
-------------------------------
Traceback (most recent call last):
File "test.py", line 147, in test_resource_leveling_1_ASAP
self._do_test_diffs(env, options, tickets, self._get_data,
'test_resource_leveling_1_ASAP')
File "test.py", line 54, in _do_test_diffs
self._do_test(env, options, tickets, testfun, testname)
File "test.py", line 50, in _do_test
open(outfilename, 'w').write(testfun(env, options, tickets))
File "test.py", line 39, in _get_data
pm.recomputeSchedule(options, tickets)
File "/home/bowenn/src/plugins/trac-jsGantt/tracjsgantt/tracpm.py",
line 1241, in recomputeSchedule
self.computeSchedule(options, tickets)
File "/home/bowenn/src/plugins/trac-jsGantt/tracjsgantt/tracpm.py",
line 1227, in computeSchedule
self.scheduler.scheduleTasks(options, ticketsByID)
File
"/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/config.py",
line 697, in __get__
self.section, self.name))
AttributeError: Cannot find an implementation of the "ITaskScheduler"
interface named "ResourceScheduler". Please update the option
TracPM.scheduler in trac.ini.
-------------------------------
I haven't set TracPM.scheduler in the config I set up for the test
because I want to rely on the default in the plugin (set via
ExtensionOption()`). My theory is that Trac instantiates all
components but since I'm not running my test in the Trac context,
there is no active instance of ResourceScheduler to find. Does that
sound right? How do I instantiate it so that ExtensionOption() will
do the right thing?
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.