def create_and_populate_indexer(factory, descriptions): indexer = altloc.Indexer( factory = factory ) inserter = altloc.Inserter( indexer = indexer ) for d in descriptions: d.accept( processor = inserter ) return indexer
def setUp(self): self.regular = [object(), object(), object()] self.altloc_a = [object(), object(), object(), object()] self.altloc_b = [object(), object()] indexer = altloc.Indexer(factory=FakeIndexer2) indexer.regular.add_to(objects=self.regular) indexer.add(altloc="A") indexer.altlocs["A"].add_to(objects=self.altloc_a) indexer.add(altloc="B") indexer.altlocs["B"].add_to(objects=self.altloc_b) self.aggregator = altloc.Aggregator(indexer=indexer)
def test_1(self): factory = lambda: object() indexer = altloc.Indexer(factory=factory) self.assertTrue(isinstance(indexer.regular, object)) self.assertEqual(indexer.factory, factory) self.assertEqual(indexer.altlocs, {}) altid = object() indexer.add(altloc=altid) self.assertTrue(altid in indexer.altlocs) self.assertTrue(isinstance(indexer.altlocs[altid], object))
def setUp(self): self.inserter = altloc.Inserter(indexer=altloc.Indexer( factory=FakeIndexer))