<s> import re <EOL> import unittest <EOL> from pyramid import testing <EOL> import BTrees <EOL> from zope . interface import ( <EOL> implementer , <EOL> alsoProvides , <EOL> ) <EOL> from hypatia . interfaces import IIndex <EOL> from ... _compat import u <EOL> _BLANK = u ( '<STR_LIT>' ) <EOL> _A = u ( '<STR_LIT:a>' ) <EOL> _B = u ( '<STR_LIT:b>' ) <EOL> def _makeSite ( ** kw ) : <EOL> from ... interfaces import IFolder <EOL> from ... interfaces import IService <EOL> site = testing . DummyResource ( __provides__ = kw . pop ( '<STR_LIT>' , None ) ) <EOL> alsoProvides ( site , IFolder ) <EOL> objectmap = kw . pop ( '<STR_LIT>' , None ) <EOL> if objectmap is not None : <EOL> site . __objectmap__ = objectmap <EOL> for k , v in kw . items ( ) : <EOL> site [ k ] = v <EOL> v . __provides__ = IService <EOL> return site <EOL> class TestCatalog ( unittest . TestCase ) : <EOL> family = BTrees . family64 <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> from zope . deprecation import __show__ <EOL> __show__ . off ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> from zope . deprecation import __show__ <EOL> __show__ . on ( ) <EOL> def _getTargetClass ( self ) : <EOL> from . . import Catalog <EOL> return Catalog <EOL> def _makeOne ( self , * arg , ** kw ) : <EOL> cls = self . _getTargetClass ( ) <EOL> inst = cls ( * arg , ** kw ) <EOL> inst . __name__ = '<STR_LIT>' <EOL> return inst <EOL> def test___sdi_addable__True ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> intr = { '<STR_LIT>' : { '<STR_LIT>' : True } } <EOL> self . assertTrue ( inst . __sdi_addable__ ( None , intr ) ) <EOL> def test___sdi_addable__False ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> intr = { '<STR_LIT>' : { } } <EOL> self . assertFalse ( inst . __sdi_addable__ ( None , intr ) ) <EOL> def test_klass_provides_ICatalog ( self ) : <EOL> klass = self . _getTargetClass ( ) <EOL> from zope . interface . verify import verifyClass <EOL> from ... interfaces import ICatalog <EOL> verifyClass ( ICatalog , klass ) <EOL> def test_inst_provides_ICatalog ( self ) : <EOL> from zope . interface . verify import verifyObject <EOL> from ... interfaces import ICatalog <EOL> inst = self . _makeOne ( ) <EOL> verifyObject ( ICatalog , inst ) <EOL> def test_flush ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> inst [ '<STR_LIT:name>' ] = idx <EOL> inst . flush ( ) <EOL> self . assertEqual ( idx . flushed , True ) <EOL> def test_reset ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . reset ( ) <EOL> self . assertEqual ( idx . cleared , True ) <EOL> def test_reset_objectids ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . objectids . insert ( <NUM_LIT:1> ) <EOL> inst . reset ( ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ ] ) <EOL> def test_ctor_defaults ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> self . assertTrue ( catalog . family is self . family ) <EOL> def test_ctor_explicit_family ( self ) : <EOL> catalog = self . _makeOne ( family = BTrees . family32 ) <EOL> self . assertTrue ( catalog . family is BTrees . family32 ) <EOL> def test_index_resource_indexes ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . index_resource ( '<STR_LIT:value>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . oid , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . resource , '<STR_LIT:value>' ) <EOL> def test_index_resource_objectids ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . index_resource ( object ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ <NUM_LIT:1> ] ) <EOL> def test_index_resource_nonint_docid ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> self . assertRaises ( TypeError , catalog . index_resource , '<STR_LIT:value>' , '<STR_LIT:abc>' ) <EOL> def test_index_resource_oid_is_None ( self ) : <EOL> resource = testing . DummyResource ( ) <EOL> resource . __oid__ = <NUM_LIT:1> <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . index_resource ( resource ) <EOL> self . assertEqual ( idx . oid , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . resource , resource ) <EOL> def test_index_doc ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . index_doc ( <NUM_LIT:1> , '<STR_LIT:value>' ) <EOL> self . assertEqual ( idx . oid , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . resource , '<STR_LIT:value>' ) <EOL> def test_unindex_resource_indexes ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . unindex_resource ( <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . unindexed , <NUM_LIT:1> ) <EOL> def test_unindex_resource_objectids_exists ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . objectids . insert ( <NUM_LIT:1> ) <EOL> inst . unindex_resource ( <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ ] ) <EOL> def test_unindex_resource_objectids_notexists ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . unindex_resource ( <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ ] ) <EOL> def test_index_resource_or_oid_is_resource_without_oid ( self ) : <EOL> resource = testing . DummyResource ( ) <EOL> catalog = self . _makeOne ( ) <EOL> self . assertRaises ( ValueError , catalog . unindex_resource , resource ) <EOL> def test_index_resource_or_oid_is_noninteger ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> self . assertRaises ( ValueError , catalog . unindex_resource , '<STR_LIT:foo>' ) <EOL> def test_unindex_doc ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . objectids . insert ( <NUM_LIT:1> ) <EOL> inst . unindex_doc ( <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ ] ) <EOL> def test_reindex_resource_indexes ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . reindex_resource ( '<STR_LIT:value>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . reindexed_oid , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . reindexed_resource , '<STR_LIT:value>' ) <EOL> def test_reindex_resource_objectids_exists ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . objectids . insert ( <NUM_LIT:1> ) <EOL> inst . reindex_resource ( object ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ <NUM_LIT:1> ] ) <EOL> def test_reindex_resource_objectids_notexists ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . reindex_resource ( object ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( inst . objectids ) , [ <NUM_LIT:1> ] ) <EOL> def test_reindex_resource_oid_is_None ( self ) : <EOL> resource = testing . DummyResource ( ) <EOL> resource . __oid__ = <NUM_LIT:1> <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . reindex_resource ( resource ) <EOL> self . assertEqual ( idx . reindexed_oid , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . reindexed_resource , resource ) <EOL> def test_reindex_doc ( self ) : <EOL> catalog = self . _makeOne ( ) <EOL> idx = DummyIndex ( ) <EOL> catalog [ '<STR_LIT:name>' ] = idx <EOL> catalog . reindex_doc ( <NUM_LIT:1> , '<STR_LIT:value>' ) <EOL> self . assertEqual ( idx . reindexed_oid , <NUM_LIT:1> ) <EOL> self . assertEqual ( idx . reindexed_resource , '<STR_LIT:value>' ) <EOL> def test_reindex ( self ) : <EOL> a = testing . DummyModel ( ) <EOL> L = [ ] <EOL> transaction = DummyTransaction ( ) <EOL> inst = self . _makeOne ( ) <EOL> inst . transaction = transaction <EOL> objectmap = DummyObjectMap ( { <NUM_LIT:1> : [ a , ( _BLANK , _A ) ] } ) <EOL> site = _makeSite ( catalog = inst , objectmap = objectmap ) <EOL> site [ '<STR_LIT:a>' ] = a <EOL> inst . objectids = [ <NUM_LIT:1> ] <EOL> def reindex_resource ( resource , oid = None , action_mode = None ) : <EOL> L . append ( ( oid , resource ) ) <EOL> inst . reindex_resource = reindex_resource <EOL> inst . flush = lambda * arg , ** kw : True <EOL> out = [ ] <EOL> inst . reindex ( output = out . append ) <EOL> self . assertEqual ( len ( L ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , a ) <EOL> self . assertEqual ( out , <EOL> [ "<STR_LIT>" , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> def test_reindex_with_missing_path ( self ) : <EOL> a = testing . DummyModel ( ) <EOL> L = [ ] <EOL> transaction = DummyTransaction ( ) <EOL> objectmap = DummyObjectMap ( <EOL> { <NUM_LIT:1> : [ a , ( _BLANK , _A ) ] , <NUM_LIT:2> : [ None , ( _BLANK , _B ) ] } <EOL> ) <EOL> inst = self . _makeOne ( ) <EOL> inst . transaction = transaction <EOL> site = _makeSite ( catalog = inst , objectmap = objectmap ) <EOL> site [ '<STR_LIT:a>' ] = a <EOL> inst . objectids = [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> def reindex_resource ( resource , oid = None , action_mode = None ) : <EOL> L . append ( ( oid , resource ) ) <EOL> inst . reindex_resource = reindex_resource <EOL> inst . flush = lambda * arg , ** kw : True <EOL> out = [ ] <EOL> inst . reindex ( output = out . append ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , a ) <EOL> self . assertEqual ( out , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> def test_reindex_with_missing_objectid ( self ) : <EOL> a = testing . DummyModel ( ) <EOL> L = [ ] <EOL> transaction = DummyTransaction ( ) <EOL> objectmap = DummyObjectMap ( ) <EOL> inst = self . _makeOne ( ) <EOL> inst . transaction = transaction <EOL> inst . flush = lambda * arg , ** kw : True <EOL> site = _makeSite ( catalog = inst , objectmap = objectmap ) <EOL> site [ '<STR_LIT:a>' ] = a <EOL> inst . objectids = [ <NUM_LIT:1> ] <EOL> out = [ ] <EOL> inst . reindex ( output = out . append ) <EOL> self . assertEqual ( L , [ ] ) <EOL> self . assertEqual ( out , <EOL> [ "<STR_LIT>" , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> def test_reindex_pathre ( self ) : <EOL> a = testing . DummyModel ( ) <EOL> b = testing . DummyModel ( ) <EOL> L = [ ] <EOL> objectmap = DummyObjectMap ( { <NUM_LIT:1> : [ a , ( _BLANK , _A ) ] , <EOL> <NUM_LIT:2> : [ b , ( _BLANK , _B ) ] } ) <EOL> transaction = DummyTransaction ( ) <EOL> inst = self . _makeOne ( ) <EOL> inst . transaction = transaction <EOL> inst . flush = lambda * arg , ** kw : True <EOL> site = _makeSite ( catalog = inst , objectmap = objectmap ) <EOL> site [ '<STR_LIT:a>' ] = a <EOL> site [ '<STR_LIT:b>' ] = b <EOL> inst . objectids = [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> def reindex_resource ( resource , oid = None , action_mode = None ) : <EOL> L . append ( ( oid , resource ) ) <EOL> inst . reindex_resource = reindex_resource <EOL> out = [ ] <EOL> inst . reindex ( <EOL> path_re = re . compile ( '<STR_LIT>' ) , <EOL> output = out . append <EOL> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , a ) <EOL> self . assertEqual ( out , <EOL> [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> def test_reindex_dryrun ( self ) : <EOL> a = testing . DummyModel ( ) <EOL> b = testing . DummyModel ( ) <EOL> L = [ ] <EOL> objectmap = DummyObjectMap ( { <NUM_LIT:1> : [ a , ( _BLANK , _A ) ] , <NUM_LIT:2> : [ b , ( _BLANK , _B ) ] } ) <EOL> transaction = DummyTransaction ( ) <EOL> inst = self . _makeOne ( ) <EOL> inst . transaction = transaction <EOL> site = _makeSite ( catalog = inst , objectmap = objectmap ) <EOL> site [ '<STR_LIT:a>' ] = a <EOL> site [ '<STR_LIT:b>' ] = b <EOL> inst . objectids = [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> def reindex_resource ( resource , oid , action_mode = None ) : <EOL> L . append ( ( oid , resource ) ) <EOL> inst . reindex_resource = reindex_resource <EOL> inst . flush = lambda * arg , ** kw : True <EOL> out = [ ] <EOL> inst . reindex ( dry_run = True , output = out . append ) <EOL> self . assertEqual ( len ( L ) , <NUM_LIT:2> ) <EOL> L . sort ( ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , a ) <EOL> self . assertEqual ( L [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <NUM_LIT:2> ) <EOL> self . assertEqual ( L [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , b ) <EOL> self . assertEqual ( out , <EOL> [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . aborted , <NUM_LIT:1> ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:0> ) <EOL> def test_reindex_with_indexes ( self ) : <EOL> a = testing . DummyModel ( ) <EOL> L = [ ] <EOL> objectmap = DummyObjectMap ( { <NUM_LIT:1> : [ a , ( _BLANK , _A ) ] } ) <EOL> transaction = DummyTransaction ( ) <EOL> inst = self . _makeOne ( ) <EOL> inst . transaction = transaction <EOL> site = _makeSite ( catalog = inst , objectmap = objectmap ) <EOL> site [ '<STR_LIT:a>' ] = a <EOL> inst . objectids = [ <NUM_LIT:1> ] <EOL> index = DummyIndex ( ) <EOL> inst [ '<STR_LIT:index>' ] = index <EOL> self . config . registry . _substanced_indexes = { '<STR_LIT:index>' : index } <EOL> def reindex_resource ( resource , oid = None , action_mode = None ) : <EOL> L . append ( ( oid , resource ) ) <EOL> index . reindex_resource = reindex_resource <EOL> inst . flush = lambda * arg , ** kw : True <EOL> out = [ ] <EOL> inst . reindex ( indexes = ( '<STR_LIT:index>' , ) , output = out . append ) <EOL> self . assertEqual ( out , <EOL> [ "<STR_LIT>" , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( L ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( L [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , a ) <EOL> def _setup_factory ( self , factory = None ) : <EOL> from substanced . interfaces import ICatalogFactory <EOL> registry = self . config . registry <EOL> if factory is None : <EOL> factory = DummyFactory ( True ) <EOL> registry . registerUtility ( factory , ICatalogFactory , name = '<STR_LIT>' ) <EOL> def test_update_indexes_nothing_to_do ( self ) : <EOL> self . _setup_factory ( DummyFactory ( False ) ) <EOL> registry = self . config . registry <EOL> out = [ ] <EOL> inst = self . _makeOne ( ) <EOL> transaction = DummyTransaction ( ) <EOL> inst . transaction = transaction <EOL> inst . update_indexes ( registry = registry , output = out . append ) <EOL> self . assertEqual ( <EOL> out , <EOL> [ '<STR_LIT>' ] , <EOL> ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:0> ) <EOL> self . assertEqual ( transaction . aborted , <NUM_LIT:0> ) <EOL> def test_update_indexes_replace ( self ) : <EOL> self . _setup_factory ( ) <EOL> registry = self . config . registry <EOL> out = [ ] <EOL> inst = self . _makeOne ( ) <EOL> transaction = DummyTransaction ( ) <EOL> inst . transaction = transaction <EOL> inst . update_indexes ( registry = registry , output = out . append , replace = True ) <EOL> self . assertEqual ( out , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> self . assertEqual ( transaction . aborted , <NUM_LIT:0> ) <EOL> self . assertTrue ( inst . replaced ) <EOL> def test_update_indexes_noreplace ( self ) : <EOL> self . _setup_factory ( ) <EOL> registry = self . config . registry <EOL> out = [ ] <EOL> inst = self . _makeOne ( ) <EOL> transaction = DummyTransaction ( ) <EOL> inst . transaction = transaction <EOL> inst . update_indexes ( registry = registry , output = out . append ) <EOL> self . assertEqual ( out , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:1> ) <EOL> self . assertEqual ( transaction . aborted , <NUM_LIT:0> ) <EOL> self . assertTrue ( inst . synced ) <EOL> def test_update_indexes_dryrun ( self ) : <EOL> self . _setup_factory ( ) <EOL> registry = self . config . registry <EOL> out = [ ] <EOL> inst = self . _makeOne ( ) <EOL> transaction = DummyTransaction ( ) <EOL> inst . transaction = transaction <EOL> inst . update_indexes ( registry = registry , output = out . append , dry_run = True ) <EOL> self . assertEqual ( out , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( transaction . committed , <NUM_LIT:0> ) <EOL> self . assertEqual ( transaction . aborted , <NUM_LIT:1> ) <EOL> class Test_is_catalogable ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> def _callFUT ( self , resource , registry = None ) : <EOL> from . . import is_catalogable <EOL> return is_catalogable ( resource , registry ) <EOL> def _registerIndexView ( self ) : <EOL> from zope . interface import Interface <EOL> from substanced . interfaces import IIndexView <EOL> self . config . registry . registerAdapter ( True , ( Interface , ) , IIndexView ) <EOL> def test_no_registry_passed ( self ) : <EOL> resource = Dummy ( ) <EOL> self . _registerIndexView ( ) <EOL> self . assertTrue ( self . _callFUT ( resource ) ) <EOL> def test_true ( self ) : <EOL> resource = Dummy ( ) <EOL> self . _registerIndexView ( ) <EOL> registry = self . config . registry <EOL> self . assertTrue ( self . _callFUT ( resource , registry ) ) <EOL> def test_false ( self ) : <EOL> resource = Dummy ( ) <EOL> registry = self . config . registry <EOL> self . assertFalse ( self . _callFUT ( resource , registry ) ) <EOL> class Test_add_catalog_factory ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> def _callFUT ( self , config , name , factory ) : <EOL> from . . import add_catalog_factory <EOL> return add_catalog_factory ( config , name , factory ) <EOL> def test_it ( self ) : <EOL> from substanced . interfaces import ICatalogFactory <EOL> from substanced . catalog import Field <EOL> config = DummyConfigurator ( registry = self . config . registry ) <EOL> class Factory ( object ) : <EOL> index = Field ( ) <EOL> self . _callFUT ( config , '<STR_LIT:name>' , Factory ) <EOL> self . assertEqual ( len ( config . actions ) , <NUM_LIT:1> ) <EOL> action = config . actions [ <NUM_LIT:0> ] <EOL> self . assertEqual ( <EOL> action [ '<STR_LIT>' ] , <EOL> ( '<STR_LIT>' , '<STR_LIT:name>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> action [ '<STR_LIT>' ] , ( config . intr , ) <EOL> ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] . __class__ . __name__ , <EOL> '<STR_LIT>' ) <EOL> callable = action [ '<STR_LIT>' ] <EOL> callable ( ) <EOL> self . assertEqual ( <EOL> self . config . registry . getUtility ( ICatalogFactory , '<STR_LIT:name>' ) , <EOL> config . intr [ '<STR_LIT>' ] <EOL> ) <EOL> class Test_add_indexview ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> def _callFUT ( <EOL> self , <EOL> config , <EOL> view , <EOL> catalog_name , <EOL> index_name , <EOL> context = None , <EOL> attr = None , <EOL> ) : <EOL> from . . import add_indexview <EOL> return add_indexview ( <EOL> config , view , catalog_name , index_name , context = context , attr = attr <EOL> ) <EOL> def test_it_func ( self ) : <EOL> from zope . interface import Interface <EOL> from substanced . interfaces import IIndexView <EOL> config = DummyConfigurator ( registry = self . config . registry ) <EOL> def view ( resource , default ) : return True <EOL> self . _callFUT ( config , view , '<STR_LIT>' , '<STR_LIT:index>' ) <EOL> self . assertEqual ( len ( config . actions ) , <NUM_LIT:1> ) <EOL> action = config . actions [ <NUM_LIT:0> ] <EOL> self . assertEqual ( <EOL> action [ '<STR_LIT>' ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:index>' , Interface ) <EOL> ) <EOL> self . assertEqual ( <EOL> action [ '<STR_LIT>' ] , ( config . intr , ) <EOL> ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , '<STR_LIT:index>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT:name>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , view ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , None ) <EOL> callable = action [ '<STR_LIT>' ] <EOL> callable ( ) <EOL> wrapper = self . config . registry . adapters . lookup ( <EOL> ( Interface , ) , IIndexView , name = '<STR_LIT>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , wrapper ) <EOL> def test_it_cls_with_attr ( self ) : <EOL> from zope . interface import Interface <EOL> from substanced . interfaces import IIndexView <EOL> config = DummyConfigurator ( registry = self . config . registry ) <EOL> class View ( object ) : <EOL> def amethod ( self , default ) : pass <EOL> self . _callFUT ( config , View , '<STR_LIT>' , '<STR_LIT:index>' , attr = '<STR_LIT>' ) <EOL> self . assertEqual ( len ( config . actions ) , <NUM_LIT:1> ) <EOL> action = config . actions [ <NUM_LIT:0> ] <EOL> self . assertEqual ( <EOL> action [ '<STR_LIT>' ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:index>' , Interface ) <EOL> ) <EOL> self . assertEqual ( <EOL> action [ '<STR_LIT>' ] , ( config . intr , ) <EOL> ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , '<STR_LIT:index>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT:name>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , View ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> callable = action [ '<STR_LIT>' ] <EOL> callable ( ) <EOL> wrapper = self . config . registry . adapters . lookup ( <EOL> ( Interface , ) , IIndexView , name = '<STR_LIT>' ) <EOL> self . assertEqual ( config . intr [ '<STR_LIT>' ] , wrapper ) <EOL> class Test_catalog_factory ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> def _makeOne ( self , name ) : <EOL> from . . import catalog_factory <EOL> return catalog_factory ( name ) <EOL> def test_it ( self ) : <EOL> class Foo ( object ) : <EOL> pass <EOL> inst = self . _makeOne ( '<STR_LIT>' ) <EOL> venusian = DummyVenusian ( ) <EOL> inst . venusian = venusian <EOL> context = testing . DummyResource ( ) <EOL> context . config = DummyConfigurator ( None ) <EOL> result = inst ( Foo ) <EOL> self . assertEqual ( result , Foo ) <EOL> venusian . callback ( context , None , '<STR_LIT:abc>' ) <EOL> self . assertEqual ( context . config . catalog_factory , ( '<STR_LIT>' , Foo ) ) <EOL> class Test_CatalogablePredicate ( unittest . TestCase ) : <EOL> def _makeOne ( self , val , config ) : <EOL> from . . import _CatalogablePredicate <EOL> return _CatalogablePredicate ( val , config ) <EOL> def test_text ( self ) : <EOL> config = Dummy ( ) <EOL> config . registry = Dummy ( ) <EOL> inst = self . _makeOne ( True , config ) <EOL> self . assertEqual ( inst . text ( ) , '<STR_LIT>' ) <EOL> def test_phash ( self ) : <EOL> config = Dummy ( ) <EOL> config . registry = Dummy ( ) <EOL> inst = self . _makeOne ( True , config ) <EOL> self . assertEqual ( inst . phash ( ) , '<STR_LIT>' ) <EOL> def test__call__ ( self ) : <EOL> config = Dummy ( ) <EOL> config . registry = Dummy ( ) <EOL> inst = self . _makeOne ( True , config ) <EOL> def is_catalogable ( context , registry ) : <EOL> self . assertEqual ( context , None ) <EOL> self . assertEqual ( registry , config . registry ) <EOL> return True <EOL> inst . is_catalogable = is_catalogable <EOL> self . assertEqual ( inst ( None , None ) , True ) <EOL> class Test_catalog_buttons ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> testing . setUp ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> def test_it ( self ) : <EOL> from . . import catalog_buttons <EOL> context = testing . DummyResource ( ) <EOL> request = testing . DummyRequest ( ) <EOL> default_buttons = [ <NUM_LIT:1> ] <EOL> buttons = catalog_buttons ( context , request , default_buttons ) <EOL> self . assertEqual ( buttons , <EOL> [ <EOL> { '<STR_LIT>' : <EOL> [ { '<STR_LIT:text>' : '<STR_LIT>' , <EOL> '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' } ] , <EOL> '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> <NUM_LIT:1> ] ) <EOL> class Test_IndexViewMapper ( unittest . TestCase ) : <EOL> def _makeOne ( self , attr = None ) : <EOL> from . . import _IndexViewMapper <EOL> return _IndexViewMapper ( attr = attr ) <EOL> def test_call_class ( self ) : <EOL> class Foo ( object ) : <EOL> def __init__ ( self , resource ) : <EOL> self . resource = resource <EOL> def __call__ ( self , default ) : <EOL> return self . resource <EOL> inst = self . _makeOne ( ) <EOL> view = inst ( Foo ) <EOL> result = view ( '<STR_LIT>' , None ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_call_class_with_attr ( self ) : <EOL> class Foo ( object ) : <EOL> def __init__ ( self , resource ) : <EOL> self . resource = resource <EOL> def meth ( self , default ) : <EOL> return self . resource <EOL> inst = self . _makeOne ( attr = '<STR_LIT>' ) <EOL> view = inst ( Foo ) <EOL> result = view ( '<STR_LIT>' , None ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_call_function ( self ) : <EOL> def foo ( resource , default ) : <EOL> return resource <EOL> inst = self . _makeOne ( ) <EOL> view = inst ( foo ) <EOL> result = view ( '<STR_LIT>' , None ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_call_function_with_attr ( self ) : <EOL> def foo ( ) : pass <EOL> def bar ( resource , default ) : <EOL> return resource <EOL> foo . bar = bar <EOL> inst = self . _makeOne ( attr = '<STR_LIT:bar>' ) <EOL> view = inst ( foo ) <EOL> result = view ( '<STR_LIT>' , None ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> class TestCatalogsService ( unittest . TestCase ) : <EOL> def _makeOne ( self , * arg , ** kw ) : <EOL> from . . import CatalogsService <EOL> inst = CatalogsService ( * arg , ** kw ) <EOL> return inst <EOL> def test_add_catalog_update_indexes_defaults_True ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . Catalog = DummyCatalog <EOL> catalog = inst . add_catalog ( '<STR_LIT:foo>' ) <EOL> self . assertTrue ( '<STR_LIT:foo>' in inst ) <EOL> self . assertTrue ( catalog . updated ) <EOL> self . assertEqual ( catalog . indexed , [ <NUM_LIT:1> ] ) <EOL> def test_add_catalog_update_indexes_false ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . Catalog = DummyCatalog <EOL> inst . add_catalog ( '<STR_LIT:foo>' , update_indexes = False ) <EOL> catalog = inst [ '<STR_LIT:foo>' ] <EOL> self . assertFalse ( catalog . __sdi_deletable__ ) <EOL> self . assertEqual ( catalog . indexed , [ <NUM_LIT:1> ] ) <EOL> def test_add_catalog_with_update_indexes ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> inst . Catalog = DummyCatalog <EOL> catalog = inst . add_catalog ( '<STR_LIT:foo>' , update_indexes = True ) <EOL> self . assertTrue ( '<STR_LIT:foo>' in inst ) <EOL> self . assertTrue ( catalog . updated ) <EOL> def test___sdi_addable__ ( self ) : <EOL> inst = self . _makeOne ( ) <EOL> self . assertFalse ( inst . __sdi_addable__ ( None , None ) ) <EOL> class Test_indexview ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> testing . setUp ( ) <EOL> def tearDown ( self ) : <EOL> testing . tearDown ( ) <EOL> def _getTargetClass ( self ) : <EOL> from substanced . catalog import indexview <EOL> return indexview <EOL> def _makeOne ( self , * arg , ** kw ) : <EOL> return self . _getTargetClass ( ) ( * arg , ** kw ) <EOL> def test_create_defaults ( self ) : <EOL> decorator = self . _makeOne ( ) <EOL> self . assertEqual ( decorator . settings , { } ) <EOL> def test_create_nondefaults ( self ) : <EOL> decorator = self . _makeOne ( <EOL> catalog_name = None , index_name = '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( decorator . settings [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( decorator . settings [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_call_as_method ( self ) : <EOL> decorator = self . _makeOne ( catalog_name = '<STR_LIT>' , context = '<STR_LIT>' ) <EOL> venusian = DummyVenusian ( ) <EOL> decorator . venusian = venusian <EOL> decorator . venusian . info . scope = '<STR_LIT:class>' <EOL> def foo ( self ) : pass <EOL> def bar ( self ) : pass <EOL> class foo ( object ) : <EOL> foomethod = decorator ( foo ) <EOL> barmethod = decorator ( bar ) <EOL> config = call_venusian ( venusian ) <EOL> settings = config . settings <EOL> self . assertEqual ( len ( settings ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT:foo>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT:foo>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_call_as_method_with_indexname ( self ) : <EOL> decorator1 = self . _makeOne ( catalog_name = '<STR_LIT>' , context = '<STR_LIT>' , <EOL> index_name = '<STR_LIT:abc>' ) <EOL> decorator2 = self . _makeOne ( catalog_name = '<STR_LIT>' , context = '<STR_LIT>' , <EOL> index_name = '<STR_LIT>' ) <EOL> venusian = DummyVenusian ( ) <EOL> decorator1 . venusian = venusian <EOL> decorator1 . venusian . info . scope = '<STR_LIT:class>' <EOL> decorator2 . venusian = venusian <EOL> decorator2 . venusian . info . scope = '<STR_LIT:class>' <EOL> def foo ( self ) : pass <EOL> def bar ( self ) : pass <EOL> class foo ( object ) : <EOL> foomethod = decorator1 ( foo ) <EOL> barmethod = decorator2 ( bar ) <EOL> config = call_venusian ( venusian ) <EOL> settings = config . settings <EOL> self . assertEqual ( len ( settings ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT:foo>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT:abc>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( settings [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_call_withdepth ( self ) : <EOL> decorator = self . _makeOne ( _depth = <NUM_LIT:1> ) <EOL> venusian = DummyVenusian ( ) <EOL> decorator . venusian = venusian <EOL> def bar ( self ) : pass <EOL> class foo ( object ) : <EOL> foomethod = decorator ( bar ) <EOL> self . assertEqual ( venusian . depth , <NUM_LIT:2> ) <EOL> class Test_indexview_defaults ( unittest . TestCase ) : <EOL> def test_it ( self ) : <EOL> from substanced . catalog import indexview_defaults <EOL> @ indexview_defaults ( route_name = '<STR_LIT:abc>' , renderer = '<STR_LIT>' ) <EOL> class Foo ( object ) : pass <EOL> self . assertEqual ( Foo . __view_defaults__ [ '<STR_LIT>' ] , '<STR_LIT:abc>' ) <EOL> self . assertEqual ( Foo . __view_defaults__ [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_it_inheritance_not_overridden ( self ) : <EOL> from substanced . catalog import indexview_defaults <EOL> @ indexview_defaults ( route_name = '<STR_LIT:abc>' , renderer = '<STR_LIT>' ) <EOL> class Foo ( object ) : pass <EOL> class Bar ( Foo ) : pass <EOL> self . assertEqual ( Bar . __view_defaults__ [ '<STR_LIT>' ] , '<STR_LIT:abc>' ) <EOL> self . assertEqual ( Bar . __view_defaults__ [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_it_inheritance_overriden ( self ) : <EOL> from substanced . catalog import indexview_defaults <EOL> @ indexview_defaults ( route_name = '<STR_LIT:abc>' , renderer = '<STR_LIT>' ) <EOL> class Foo ( object ) : pass <EOL> @ indexview_defaults ( route_name = '<STR_LIT>' ) <EOL> class Bar ( Foo ) : pass <EOL> self . assertEqual ( Bar . __view_defaults__ [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertFalse ( '<STR_LIT>' in Bar . __view_defaults__ ) <EOL> def test_it_inheritance_overriden_empty ( self ) : <EOL> from substanced . catalog import indexview_defaults <EOL> @ indexview_defaults ( route_name = '<STR_LIT:abc>' , renderer = '<STR_LIT>' ) <EOL> class Foo ( object ) : pass <EOL> @ indexview_defaults ( ) <EOL> class Bar ( Foo ) : pass <EOL> self . assertEqual ( Bar . __view_defaults__ , { } ) <EOL> class DummyIntrospectable ( dict ) : <EOL> pass <EOL> class DummyConfigurator ( object ) : <EOL> _ainfo = None <EOL> def __init__ ( self , registry ) : <EOL> self . actions = [ ] <EOL> self . intr = DummyIntrospectable ( ) <EOL> self . registry = registry <EOL> self . indexes = [ ] <EOL> def action ( self , discriminator , callable , order = None , introspectables = ( ) ) : <EOL> self . actions . append ( <EOL> { <EOL> '<STR_LIT>' : discriminator , <EOL> '<STR_LIT>' : callable , <EOL> '<STR_LIT>' : order , <EOL> '<STR_LIT>' : introspectables , <EOL> } ) <EOL> def with_package ( self , package ) : <EOL> return self <EOL> def introspectable ( self , category , discriminator , name , single ) : <EOL> return self . intr <EOL> def add_catalog_factory ( self , name , cls , ** extra ) : <EOL> self . catalog_factory = ( name , cls ) <EOL> def maybe_dotted ( self , view ) : <EOL> return view <EOL> class DummyObjectMap ( object ) : <EOL> def __init__ ( self , objectid_to = None ) : <EOL> if objectid_to is None : objectid_to = { } <EOL> self . objectid_to = objectid_to <EOL> def path_for ( self , objectid ) : <EOL> data = self . objectid_to . get ( objectid ) <EOL> if data is None : return <EOL> return data [ <NUM_LIT:1> ] <EOL> def object_for ( self , objectid ) : <EOL> data = self . objectid_to . get ( objectid ) <EOL> if data is None : <EOL> return <EOL> return data [ <NUM_LIT:0> ] <EOL> def add ( self , node , path_tuple , duplicating = False , moving = False ) : <EOL> pass <EOL> class DummyCatalog ( dict ) : <EOL> __oid__ = <NUM_LIT:1> <EOL> def __init__ ( self ) : <EOL> self . indexed = [ ] <EOL> def update_indexes ( self , * arg , ** kw ) : <EOL> self . updated = True <EOL> def index_resource ( self , resource , oid = None , action_mode = None ) : <EOL> self . indexed . append ( oid ) <EOL> class DummyTransaction ( object ) : <EOL> def __init__ ( self ) : <EOL> self . committed = <NUM_LIT:0> <EOL> self . aborted = <NUM_LIT:0> <EOL> def commit ( self ) : <EOL> self . committed += <NUM_LIT:1> <EOL> def abort ( self ) : <EOL> self . aborted += <NUM_LIT:1> <EOL> @ implementer ( IIndex ) <EOL> class DummyIndex ( object ) : <EOL> resource = None <EOL> oid = None <EOL> action_mode = None <EOL> limit = None <EOL> sort_type = None <EOL> def __init__ ( self , * arg , ** kw ) : <EOL> self . arg = arg <EOL> self . kw = kw <EOL> def flush ( self , all ) : <EOL> self . flushed = all <EOL> def index_resource ( self , resource , oid = None , action_mode = None ) : <EOL> self . resource = resource <EOL> self . oid = oid <EOL> self . action_mode = action_mode <EOL> def unindex_resource ( self , oid , action_mode = None ) : <EOL> self . unindexed = oid <EOL> def reindex_resource ( self , resource , oid = None , action_mode = None ) : <EOL> self . reindexed_oid = oid <EOL> self . reindexed_resource = resource <EOL> def reset ( self ) : <EOL> self . cleared = True <EOL> def apply_intersect ( self , query , docids ) : <EOL> if docids is None : <EOL> return self . arg [ <NUM_LIT:0> ] <EOL> L = [ ] <EOL> for docid in self . arg [ <NUM_LIT:0> ] : <EOL> if docid in docids : <EOL> L . append ( docid ) <EOL> return L <EOL> class Dummy ( object ) : <EOL> pass <EOL> class DummyFactory ( object ) : <EOL> def __init__ ( self , result ) : <EOL> self . result = result <EOL> def replace ( self , catalog , ** kw ) : <EOL> catalog . replaced = True <EOL> return self . result <EOL> def sync ( self , catalog , ** kw ) : <EOL> catalog . synced = True <EOL> return self . result <EOL> class DummyVenusianInfo ( object ) : <EOL> scope = None <EOL> codeinfo = None <EOL> module = None <EOL> def __init__ ( self , ** kw ) : <EOL> self . __dict__ . update ( kw ) <EOL> class DummyVenusian ( object ) : <EOL> def __init__ ( self , info = None ) : <EOL> if info is None : <EOL> info = DummyVenusianInfo ( ) <EOL> self . info = info <EOL> self . attachments = [ ] <EOL> def attach ( self , wrapped , callback , category , depth = <NUM_LIT:1> ) : <EOL> self . attachments . append ( ( wrapped , callback , category ) ) <EOL> self . wrapped = wrapped <EOL> self . callback = callback <EOL> self . category = category <EOL> self . depth = depth <EOL> return self . info <EOL> class DummyRegistry ( object ) : <EOL> pass <EOL> class DummyConfig ( object ) : <EOL> def __init__ ( self ) : <EOL> self . settings = [ ] <EOL> self . registry = DummyRegistry ( ) <EOL> def add_indexview ( self , ob , ** kw ) : <EOL> self . settings . append ( kw ) <EOL> def with_package ( self , pkg ) : <EOL> self . pkg = pkg <EOL> return self <EOL> class DummyVenusianContext ( object ) : <EOL> def __init__ ( self ) : <EOL> self . config = DummyConfig ( ) <EOL> def call_venusian ( venusian , context = None ) : <EOL> if context is None : <EOL> context = DummyVenusianContext ( ) <EOL> for wrapped , callback , category in venusian . attachments : <EOL> callback ( context , None , None ) <EOL> return context . config </s>
