Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utils test / fix unicode bug in utils.
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,7 @@ | |
.mr.developer.cfg | ||
bin/ | ||
buildout.cfg | ||
coverage/ | ||
develop-eggs/ | ||
parts/ | ||
var/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from ftw.tagging import utils | ||
from ftw.tagging.interfaces.tagging import ITaggable, ITagRoot | ||
from ftw.testing import MockTestCase | ||
|
||
|
||
class TestUtils(MockTestCase): | ||
|
||
def setUp(self): | ||
portal_url = self.stub() | ||
self.mock_tool(portal_url, 'portal_url') | ||
self.portal = self.stub() | ||
self.expect(portal_url.getPortalObject()).result(self.portal) | ||
|
||
def test_getInterfaceRoot(self): | ||
root = self.providing_stub([ITagRoot]) | ||
|
||
obj = self.set_parent( | ||
self.stub(), | ||
self.set_parent( | ||
self.stub(), | ||
self.set_parent( | ||
root, | ||
self.portal))) | ||
|
||
self.replay() | ||
|
||
self.assertEqual(utils.getInterfaceRoot(obj, ITagRoot), root) | ||
|
||
def test_getInterfaceRoot_when_root_reached(self): | ||
obj = self.set_parent( | ||
self.stub(), | ||
self.portal) | ||
|
||
self.replay() | ||
|
||
self.assertEqual(utils.getInterfaceRoot(obj, ITagRoot), self.portal) | ||
|
||
|
||
def test_getTagRootTags(self): | ||
brain1 = self.stub() | ||
self.expect(brain1.tags).result(('foo', 'bar', u'\xe4', '\xc3\xa4')) | ||
brain2 = self.stub() | ||
self.expect(brain2.tags).result(('bar', u'baz')) | ||
brain3 = self.stub() | ||
self.expect(brain3.tags).result(None) | ||
|
||
root = self.providing_stub([ITagRoot]) | ||
obj = self.set_parent(self.stub(), root) | ||
self.expect(root.getPhysicalPath()).result(['', 'path', 'to', 'root']) | ||
|
||
catalog = self.stub() | ||
self.mock_tool(catalog, 'portal_catalog') | ||
query = {'path': '/path/to/root', | ||
'object_provides': ITaggable.__identifier__} | ||
self.expect(catalog(query)).result([brain1, brain2]) | ||
|
||
self.replay() | ||
|
||
self.assertEqual(set(utils.getTagRootTags(obj)), | ||
set(['foo', 'bar', 'baz', '\xc3\xa4'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
tests_require = [ | ||
'collective.testcaselayer', | ||
'Products.PloneTestCase', | ||
'ftw.testing', | ||
] | ||
|
||
|
||
|