-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from NextThought/issue30
Optimize and cache the signature computation for update.updateFromExternalObject
- Loading branch information
Showing
14 changed files
with
346 additions
and
78 deletions.
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
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
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
Empty file.
49 changes: 49 additions & 0 deletions
49
src/nti/externalization/externalization/tests/test_externalizer.py
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,49 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
# disable: accessing protected members, too many methods | ||
# pylint: disable=W0212,R0904 | ||
|
||
import unittest | ||
|
||
from zope.proxy import ProxyBase | ||
|
||
from nti.externalization.externalization import to_external_object | ||
from ..externalizer import _obj_has_usable_externalObject | ||
|
||
|
||
class WithToExternalObject(object): | ||
|
||
def toExternalObject(self, **kwargs): | ||
return {'a': 42} | ||
|
||
|
||
|
||
class TestFunctions(unittest.TestCase): | ||
|
||
def test_non_proxied(self): | ||
self.assertTrue(_obj_has_usable_externalObject(WithToExternalObject())) | ||
|
||
def test_has_usable_external_object_proxied(self): | ||
|
||
obj = WithToExternalObject() | ||
proxied = ProxyBase(obj) | ||
|
||
self.assertTrue(_obj_has_usable_externalObject(proxied)) | ||
self.assertEqual({'a': 42}, to_external_object(proxied)) | ||
|
||
def test_proxy_has_usable_external_object_not_allowed(self): | ||
|
||
class Proxy(ProxyBase): | ||
|
||
def toExternalObject(self, **kwargs): | ||
raise NotImplementedError | ||
|
||
self.assertFalse(_obj_has_usable_externalObject(Proxy(object()))) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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
Oops, something went wrong.