def test_origin_caller(self): """ verify that Origin.get_caller_origin() uses PythonFileTextSource as the origin.source attribute. """ self.assertIsInstance( Origin.get_caller_origin().source, PythonFileTextSource)
def test_origin_caller(self): """ verify that Origin.get_caller_origin() uses PythonFileTextSource as the origin.source attribute. """ self.assertIsInstance(Origin.get_caller_origin().source, PythonFileTextSource)
def test_origin_source_filename_is_correct(self): """ verify that make_job() can properly trace the filename of the python module that called make_job() """ # Pass -1 to get_caller_origin() to have filename point at this file # instead of at whatever ends up calling the test method self.assertEqual( os.path.basename(Origin.get_caller_origin(-1).source.filename), "test_rfc822.py")
def test_origin_source_filename_is_correct(self): """ verify that make_job() can properly trace the filename of the python module that called make_job() """ # Pass -1 to get_caller_origin() to have filename point at this file # instead of at whatever ends up calling the test method self.assertEqual( os.path.basename(Origin.get_caller_origin(-1).source.filename), "test_rfc822.py")
def __init__(self, data, origin=None, provider=None, controller=None): super(JobDefinition, self).__init__(data) if origin is None: origin = Origin.get_caller_origin() if controller is None: # XXX: moved here because of cyclic imports from plainbox.impl.ctrl import checkbox_session_state_ctrl controller = checkbox_session_state_ctrl self._resource_program = None self._origin = origin self._provider = provider self._controller = controller
def make_job(id, plugin="dummy", requires=None, depends=None, **kwargs): """ Make and return a dummy JobDefinition instance """ data = {'id': id} if plugin is not None: data['plugin'] = plugin if requires is not None: data['requires'] = requires if depends is not None: data['depends'] = depends # Add any custom key-value properties data.update(kwargs) return JobDefinition(data, Origin.get_caller_origin())
def make_job(id, plugin="dummy", requires=None, depends=None, **kwargs): """ Make and return a dummy JobDefinition instance """ data = {'id': id} if plugin is not None: data['plugin'] = plugin if requires is not None: data['requires'] = requires if depends is not None: data['depends'] = depends # Add any custom key-value properties data.update(kwargs) return JobDefinition(data, Origin.get_caller_origin())
def __init__(self, data, origin=None, provider=None, controller=None, raw_data=None): """ Initialize a new JobDefinition instance. :param data: Normalized data that makes up this job definition :param origin: An (optional) Origin object. If omitted a fake origin object is created. Normally the origin object should be obtained from the RFC822Record object. :param provider: An (optional) Provider1 object. If omitted it defaults to None but the actual job definition is not suitable for execution. All job definitions are expected to have a provider. :param controller: An (optional) session state controller. If omitted a checkbox session state controller is implicitly used. The controller defines how this job influences the session it executes in. :param raw_data: An (optional) raw version of data, without whitespace normalization. If omitted then raw_data is assumed to be data. .. note:: You should almost always use :meth:`from_rfc822_record()` instead. """ super(JobDefinition, self).__init__(data, raw_data) if origin is None: origin = Origin.get_caller_origin() if controller is None: # XXX: moved here because of cyclic imports from plainbox.impl.ctrl import checkbox_session_state_ctrl controller = checkbox_session_state_ctrl self._resource_program = None self._origin = origin self._provider = provider self._controller = controller