| | 499 | |
|---|
| | 500 | def test_getNodeInfo(self): |
|---|
| | 501 | self.makeInfrastructure() |
|---|
| | 502 | cmf = self.app.cmf |
|---|
| | 503 | tool = cmf.portal_trees |
|---|
| | 504 | cache = tool.cache |
|---|
| | 505 | cache_upd = TreeCacheUpdater(cache) |
|---|
| | 506 | |
|---|
| | 507 | # test on ordinary object |
|---|
| | 508 | info = cache_upd.getNodeInfo(cmf.root.foo) |
|---|
| | 509 | self.assertEquals(info, |
|---|
| | 510 | {'allowed_roles_and_users': ['Manager'], |
|---|
| | 511 | 'title': 'Foo', |
|---|
| | 512 | 'local_roles': {'user:Anonymous User': ('Owner',)}, |
|---|
| | 513 | 'rpath': 'root/foo', |
|---|
| | 514 | 'portal_type': 'ThePortalType', |
|---|
| | 515 | 'id': 'foo'}) |
|---|
| | 516 | |
|---|
| | 517 | # test on proxy |
|---|
| | 518 | from Products.CPSCore.ProxyBase import ProxyFolder |
|---|
| | 519 | cmf.root._setObject('bar', ProxyFolder('bar')) |
|---|
| | 520 | |
|---|
| | 521 | class DummyObjectTitle(DummyObject): |
|---|
| | 522 | # subclass was preferd to adding the method to DummyObject |
|---|
| | 523 | # in order to be sure not to void tests of info_method system |
|---|
| | 524 | |
|---|
| | 525 | def Title(self): |
|---|
| | 526 | return self.title |
|---|
| | 527 | |
|---|
| | 528 | cmf.root._setObject('bar_en', DummyObjectTitle('bar_en', |
|---|
| | 529 | title='English title')) |
|---|
| | 530 | cmf.root._setObject('bar_fr', DummyObjectTitle('bar_fr', |
|---|
| | 531 | title='French title')) |
|---|
| | 532 | cmf.root.bar.portal_type = cmf.root.bar_en.portal_type |
|---|
| | 533 | |
|---|
| | 534 | # monkey patch of bar's getContent to avoid proxy and repo tool faking |
|---|
| | 535 | def getContent(lang='default', **kw): |
|---|
| | 536 | if lang in ['default', 'en']: |
|---|
| | 537 | return cmf.root.bar_en |
|---|
| | 538 | elif lang == 'fr': |
|---|
| | 539 | return cmf.root.bar_fr |
|---|
| | 540 | |
|---|
| | 541 | def getProxyLanguages(): |
|---|
| | 542 | return ['fr', 'en'] |
|---|
| | 543 | |
|---|
| | 544 | bar = cmf.root.bar |
|---|
| | 545 | bar.getContent = getContent |
|---|
| | 546 | bar.getProxyLanguages = getProxyLanguages |
|---|
| | 547 | |
|---|
| | 548 | info = cache_upd.getNodeInfo(cmf.root.bar) |
|---|
| | 549 | self.assertEquals(info, {'allowed_roles_and_users': ['Manager'], |
|---|
| | 550 | 'local_roles': { |
|---|
| | 551 | 'user:Anonymous User': ('Owner',)}, |
|---|
| | 552 | 'title': 'English title', |
|---|
| | 553 | 'l10_titles': {'fr': 'French title', |
|---|
| | 554 | 'en': 'English title'}, |
|---|
| | 555 | 'rpath': 'root/bar', |
|---|
| | 556 | 'portal_type': 'ThePortalType', |
|---|
| | 557 | 'id': 'bar'}) |
|---|