本文整理汇总了Python中stubydoo.double函数的典型用法代码示例。如果您正苦于以下问题:Python double函数的具体用法?Python double怎么用?Python double使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了double函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
placelesssetup.setUp(self)
self.mailhost = stubydoo.double()
class IPossibleSubscriberProvider(zope.interface.Interface):
pass
self.subscriber = stubydoo.double()
self.subscribers = [self.subscriber]
self.newsletter = stubydoo.double()
self.message = stubydoo.double()
stubydoo.stub(self.newsletter, 'compile').with_args(self.subscriber).\
and_return(self.message)
stubydoo.stub(self.mailhost, 'send').with_args(self.message)
@zope.component.adapter(None)
@zope.interface.implementer(interfaces.INewsletter)
def newsletter_adapter(context):
self.newsletter.context = context
return self.newsletter
zope.component.provideAdapter(newsletter_adapter)
self.context = stubydoo.double()
self.mailing = mailing.Mailing()
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:25,代码来源:test_mailing.py
示例2: setUp
def setUp(self):
placelesssetup.setUp(self)
self.configuration = GlobalConfiguration(
subscriber_name_xpath=u'',
add_subscriber_preferences=False,
subscriber_preferences_url_xpath=u'',
subscriber_preferences_html=u'',
add_subscriber_removal=True,
subscriber_removal_url_xpath=u'',
subscriber_removal_html=u'',
inline_styles=False,
)
zope.component.provideUtility(self.configuration)
self.newsletter_attributes = stubydoo.double()
self.context = stubydoo.double()
request = object()
self.newsletter = newsletter.Newsletter(self.context,
request,
self.newsletter_attributes)
self.message_factory = stubydoo.double(__call__=lambda x, c: c)
@zope.component.adapter(None, None, None, None)
@zope.interface.implementer(interfaces.IMessageFactory)
def message_factory_factory(context, request, newsletter, subscriber):
return self.message_factory
zope.component.provideAdapter(message_factory_factory)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:30,代码来源:test_newsletter.py
示例3: setUp
def setUp(self):
placelesssetup.setUp(self)
self.config = stubydoo.double()
# This kind of document uses a rich text field, which has an output
# attribute.
self.document = stubydoo.double(body=stubydoo.double())
self.document.body = u'<p>Test!</p>'
@zope.component.adapter(None)
@zope.interface.implementer(interfaces.IHTMLBody)
def html_body(doc):
return doc.body
zope.component.provideAdapter(html_body)
self.compiler = StyledPageCompilationStrategy(self.document, self.config)
# This 'stubbing' relies on the fact that the function is accessed
# through module's getattr always, no references kept.
from tn.plonestyledpage import styled_page
self.old_getUniqueId = styled_page.getUniqueId
styled_page.getUniqueId = lambda page: u'foo'
self.old_getEscapedStyleBlock = styled_page.getEscapedStyleBlock
styled_page.getEscapedStyleBlock = lambda page: u'<style>%s</style>' % page.styles
self.document.styles = u'p{color:red}'
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:27,代码来源:test_compilation_strategy.py
示例4: test_compilation_with_default_xpath_and_css
def test_compilation_with_default_xpath_and_css(self):
context = double()
configuration = double(
xpath=NullTemplateConfiguration.xpath,
css=NullTemplateConfiguration.css,
html=u'<html><body></body></html>'
)
@zope.component.adapter(None)
@zope.interface.implementer(interfaces.IHTMLBody)
def body_adapter(context):
return double(__unicode__=lambda self:u'<p>Hello</p>')
zope.component.provideAdapter(body_adapter)
expected_body = u'<body><p>Hello</p></body>'
strategy = CompilationStrategy(context, configuration)
result = strategy.compile()
resulting_body = lxml.html.document_fromstring(result).\
xpath(u'//body')[0]
self.assertEquals(
expected_body,
lxml.html.tostring(resulting_body)
)
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:25,代码来源:test_compilation_strategy.py
示例5: test_delegates_to_adapters
def test_delegates_to_adapters(self):
context = double()
content = double(body=u'body')
zope.interface.alsoProvides(context, IAttributeAnnotatable)
template = Template(context)
self.assertEquals(template.compile(content), u'html(body)')
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:8,代码来源:test_template.py
示例6: test_traversing_to_a_unknown_key_redirects
def test_traversing_to_a_unknown_key_redirects(self):
response = double(redirect=lambda self, url:None)
request = double(response=response)
expect(response.redirect).with_args('the original url')
cache_keys = zope.component.getUtility(interfaces.ICacheKeys)
stub(cache_keys.getURL).with_args('unknown key').\
and_return('the original url')
self.cache_traverser.publishTraverse(request, 'unknown key')
开发者ID:tecnologiaenegocios,项目名称:tn.plonehtmlimagecache,代码行数:10,代码来源:test_caching.py
示例7: setUp
def setUp(self):
placelesssetup.setUp(self)
self.metadata = double(language='klingon')
@zope.component.adapter(None)
@zope.interface.implementer(ICategorization)
def metadata(context):
return self.metadata
zope.component.provideAdapter(metadata)
self.context = double(title=u'Content title')
self.configuration = NullTemplateConfiguration(self.context)
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:13,代码来源:test_template.py
示例8: test_returns_null_template_object_if_template_is_emptied
def test_returns_null_template_object_if_template_is_emptied(self):
relation = double(to_object='template object')
self.templating.template = relation
self.templating.template = None
template = self.templating.template_object
self.assertTrue(isinstance(template, NullTemplate))
self.assertTrue(template.context is self.context)
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:8,代码来源:test_template.py
示例9: test_traversing_to_a_known_key_marks_request_for_publishing
def test_traversing_to_a_known_key_marks_request_for_publishing(self):
value = object()
request = double()
self.cache_manager['the key'] = value
self.cache_traverser.publishTraverse(request, 'the key')
self.assertTrue(interfaces.ICacheRequest.providedBy(request))
开发者ID:tecnologiaenegocios,项目名称:tn.plonehtmlimagecache,代码行数:8,代码来源:test_caching.py
示例10: test_traversing_to_a_known_key
def test_traversing_to_a_known_key(self):
value = object()
request = double()
self.cache_manager['the key'] = value
traversed = self.cache_traverser.publishTraverse(request, 'the key')
self.assertTrue(traversed is value)
开发者ID:tecnologiaenegocios,项目名称:tn.plonehtmlimagecache,代码行数:8,代码来源:test_caching.py
示例11: setUp
def setUp(self):
placelesssetup.setUp(self)
self.context = zope.container.folder.Folder()
self.request = stubydoo.double(form={})
self.add_form = AddForm(self.context)
self.adder = subscriber_list.SubscriberAdder(self.context,
self.request,
self.add_form)
dates_locale = stubydoo.double()
self.request.locale = stubydoo.double(dates=dates_locale)
self.parsed_datetime = datetime.datetime.now()
self.date_short_fmt = stubydoo.double(
parse=lambda f, x: self.parsed_datetime
)
stubydoo.stub(dates_locale, 'getFormatter').\
with_args('date', 'short').and_return(self.date_short_fmt)
stubydoo.stub(dates_locale, 'getFormatter').\
with_args('date', 'medium').\
and_return(stubydoo.double(parse='ignored'))
stubydoo.stub(dates_locale, 'getFormatter').\
with_args('dateTime', 'short').\
and_return(stubydoo.double(parse='ignored'))
stubydoo.stub(dates_locale, 'getFormatter').\
with_args('dateTime', 'medium').\
and_return(stubydoo.double(parse='ignored'))
zope.component.provideAdapter(Publication)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:31,代码来源:test_subscriber_list.py
示例12: test_add_adds_subscriber_with_form_data
def test_add_adds_subscriber_with_form_data(self):
obj = stubydoo.double()
obj.id = 'the subscriber id'
stubydoo.stub(self.add_form.extractData).\
and_return(('the data', None))
stubydoo.expect(self.add_form.createAndAdd).\
with_args('the data').and_return(obj)
self.adder.add('email', 'format', None, None)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:10,代码来源:test_subscriber_list.py
示例13: configure_newsletter_from_content_behavior
def configure_newsletter_from_content_behavior(self):
self.behavior = stubydoo.double(subscribers=self.subscribers)
@zope.component.adapter(None)
@zope.interface.implementer(behaviors.INewsletterFromContent)
def behavior_adapter(context):
return self.behavior
zope.component.provideAdapter(behavior_adapter)
# This is normally registered during application startup.
zope.component.provideHandler(zope.component.event.objectEventNotify)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:11,代码来源:test_mailing.py
示例14: setUp
def setUp(self):
placelesssetup.setUp(self)
self.cache = {}
self.context_keys = double(link=lambda *a:None,
unlink=lambda *a:None,
unlinkContext=lambda *a:None,
__contains__=lambda *a:True)
zope.component.provideUtility(self.cache, interfaces.ICache)
zope.component.provideUtility(self.context_keys,
interfaces.IContextKeys)
self.cache_manager = caching.CacheManager()
开发者ID:tecnologiaenegocios,项目名称:tn.plonehtmlimagecache,代码行数:11,代码来源:test_caching.py
示例15: test_compiles_template_with_context
def test_compiles_template_with_context(self):
compilation = double()
stubydoo.stub(compilation, '__unicode__').and_return(u'Result')
@zope.component.adapter(None)
@zope.interface.implementer(interfaces.ICompilation)
def compilation_adapter(context):
return compilation
zope.component.provideAdapter(compilation_adapter)
self.assertEquals(self.view.render(), u'Result')
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:12,代码来源:test_template.py
示例16: setUp
def setUp(self):
placelesssetup.setUp(self)
zope.component.provideUtility(intids)
portal = stubydoo.double(
email_from_address="the site's email address",
email_from_name="the site's name"
)
self.context = stubydoo.double()
self.context.portal_url = stubydoo.double(
getPortalObject=lambda x: portal
)
zope.interface.alsoProvides(portal,
plone.app.controlpanel.mail.IMailSchema)
self.behavior = stubydoo.double()
@zope.component.adapter(None)
@zope.interface.implementer(behaviors.INewsletterFromContent)
def newsletter_from_content(context):
return self.behavior
zope.component.provideAdapter(newsletter_from_content)
@zope.component.adapter(None)
@zope.interface.implementer(zope.annotation.interfaces.IAnnotations)
def annotations_adapter(context):
annotations = getattr(context, '_annotations', None)
if annotations is None:
context._annotations = dict()
return context._annotations
zope.component.provideAdapter(annotations_adapter)
self.adapted = behaviors.NewsletterAttributes(self.context)
self.original_getToolByName_code = getToolByName.func_code
getToolByName_stup = lambda context, name: getattr(context, name)
getToolByName.func_code = getToolByName_stup.func_code
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:39,代码来源:test_behaviors.py
示例17: test_notify_modification
def test_notify_modification(self):
@zope.component.adapter(None, IObjectModifiedEvent)
def handler(object, event):
self.object = object
self.event = event
zope.component.provideHandler(handler)
newsletter.setLastSent(self.context, stubydoo.double())
self.assertTrue(self.object is self.context)
self.assertEquals(self.event.descriptions[0].attributes,
('last_sent',))
self.assertTrue(self.event.descriptions[0].interface is
interfaces.INewsletterAttributes)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:13,代码来源:test_newsletter.py
示例18: test_add_should_set_subscriber_deactivation_date
def test_add_should_set_subscriber_deactivation_date(self):
# Don't break if the subscriber is to be wrapped.
obj = stubydoo.double(__of__=lambda self, container: self)
obj.id = 'the subscriber id'
stubydoo.stub(self.add_form.extractData).\
and_return(('the data', None))
stubydoo.stub(self.add_form.createAndAdd).\
with_args('the data').and_return(obj)
self.adder.add('email', 'format', None, 'deactivation')
self.assertEquals(subscriber.getSubscriberDeactivation(obj),
self.parsed_datetime)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:14,代码来源:test_subscriber_list.py
示例19: test_send_should_be_able_to_not_fire_event
def test_send_should_be_able_to_not_fire_event(self):
testpoint = stubydoo.double(event_called=lambda x: None)
@zope.component.adapter(None, interfaces.INewsletterSentEvent)
def handler(object, event):
testpoint.event_called()
zope.component.provideHandler(handler)
stubydoo.expect(testpoint.event_called).to_not_be_called
self.mailing.send(self.context,
suppress_events=True,
mailhost=self.mailhost,
subscribers=self.subscribers)
开发者ID:tecnologiaenegocios,项目名称:tn.plonemailing,代码行数:14,代码来源:test_mailing.py
示例20: test_get_language_from_portal_if_content_has_no_language
def test_get_language_from_portal_if_content_has_no_language(self):
self.metadata = None
portal_state_view = double(default_language=lambda self: 'mayan')
@zope.component.adapter(None, None)
@zope.interface.implementer(
zope.publisher.interfaces.browser.IBrowserView
)
def view(context, request):
return portal_state_view
zope.component.provideAdapter(view, name=u'plone_portal_state')
tree = lxml.html.document_fromstring(self.configuration.html)
lang = tree.xpath('/html/@lang')[0]
self.assertEquals(lang, 'mayan')
开发者ID:tecnologiaenegocios,项目名称:tn.plonebehavior.template,代码行数:15,代码来源:test_template.py
注:本文中的stubydoo.double函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论