async def run2(db): ob = test_utils.create_content() start = time.time() for _ in range(ITERATIONS): getAdapter(ob, ISecurityInfo) end = time.time() print(f'Done with {ITERATIONS} in {end - start} seconds')
async def run1(): ob = test_utils.create_content() print("Test single adapter lookup") start = time.time() for _ in range(ITERATIONS): getAdapter(ob, ISecurityInfo) end = time.time() print(f"Done with {ITERATIONS} in {end - start} seconds")
async def run1(): ob = test_utils.create_content() print('Test single adapter lookup') start = time.time() for _ in range(ITERATIONS): getAdapter(ob, ISecurityInfo) end = time.time() print(f'Done with {ITERATIONS} in {end - start} seconds')
async def test_get_security_data(dummy_request): request = dummy_request # noqa ob = test_utils.create_content() adapter = getAdapter(ob, ISecurityInfo) data = adapter() assert 'access_users' in data assert 'access_roles' in data
def test_configuration_machine_allows_overriding(): from guillotina.configure.config import ConfigurationMachine from guillotina.configure import component from guillotina.component import adapter, named, getAdapter from zope.interface import implementer, Interface class IFoo(Interface): pass @implementer(IFoo) class Foo(object): pass class IBar(Interface): pass cm = ConfigurationMachine() @adapter(IFoo) @implementer(IBar) @named('bar') class _Factory(object): def __init__(self, context): self.context = context class _FactoryOverride(_Factory): pass component.adapter(cm, (_Factory, )) cm.execute_actions() cm.commit() component.adapter(cm, (_FactoryOverride, )) cm.execute_actions() adapter = getAdapter(Foo(), name='bar') assert isinstance(adapter, _FactoryOverride)
def _callFUT(self, *args, **kw): from guillotina.component import getAdapter return getAdapter(*args, **kw)
async def test_RootSpecialPermissions_IApplication(dummy_guillotina): root = getUtility(IApplication, name='root') adapter = getAdapter(root, interface=IPrincipalPermissionManager) assert isinstance(adapter, ApplicationSpecialPermissions)
async def test_DatabaseSpecialPermissions_IDatabase(dummy_txn_root): async with await dummy_txn_root as root: adapter = getAdapter(root, interface=IPrincipalPermissionManager) assert isinstance(adapter, DatabaseSpecialPermissions)
def test_get_current_interaction(dummy_request): adapter = getAdapter(dummy_request, interface=IInteraction) assert isinstance(adapter, Interaction)
def test_vocabulary(): from guillotina.schema.vocabulary import SimpleVocabulary vocab = SimpleVocabulary.fromItems( ((u"Foo", "id_foo"), (u"Bar", "id_bar"))) res = getAdapter(vocab, interface=IValueToJson) assert type(res) == list