def test_all(self):
        class Mock(IdentifierResolutionCoverageProvider):
            def gather_providers(self, provider_kwargs):
                return []

        # We have 3 collections created here, plus the 'unaffiliated'
        # collection.
        unaffiliated, ignore = IdentifierResolutionCoverageProvider.unaffiliated_collection(self._db)
        for i in range(3):
            collection = self._collection()

        # all() puts them in random order (not tested), but
        # the unaffiliated collection is always last.
        providers = Mock.all(self._db, mirror=object())
        providers = list(providers)
        eq_(4, len(providers))
        eq_(unaffiliated, providers[-1].collection)
 def default_collection(self):
     if getattr(self, '_default_collection_id', None) is None:
         default_collection, ignore = IdentifierResolutionCoverageProvider.unaffiliated_collection(self._db)
         self._default_collection_id = default_collection.id
     return get_one(self._db, Collection, id=self._default_collection_id)
Пример #3
0
 def default_collection(self):
     if getattr(self, '_default_collection_id', None) is None:
         default_collection, ignore = IdentifierResolutionCoverageProvider.unaffiliated_collection(
             self._db)
         self._default_collection_id = default_collection.id
     return get_one(self._db, Collection, id=self._default_collection_id)