def setUp(self): super(IndexRegistryTests, self).setUp() self.ir = IndexRegistry()
class IndexRegistryTests(BaseTestCase): def setUp(self): super(IndexRegistryTests, self).setUp() self.ir = IndexRegistry() def test_register(self): self.ir.register('Artist', 'person_id') assert 'Artist' in self.ir._data assert self.ir._data['Artist'] == set(['person_id']) def test_register_same(self): self.ir.register('Artist', 'person_id') self.ir.register('Artist', 'person_id') assert 'Artist' in self.ir._data assert self.ir._data['Artist'] == set(['person_id']) def test_unregister(self): self.ir.register('Artist', 'person_id') self.ir.unregister('Artist', 'person_id') assert 'Artist' in self.ir._data assert self.ir._data['Artist'] == set() def test_unregister_same(self): self.ir.register('Artist', 'person_id') self.ir.unregister('Artist', 'person_id') self.ir.unregister('Artist', 'person_id') assert 'Artist' in self.ir._data assert self.ir._data['Artist'] == set() def test_get_for_model(self): self.ir.register('Artist', 'person_id') assert self.ir.get_for_model('Artist') == set(['person_id']) def test_get_for_inexistent_model(self): assert self.ir.get_for_model('Artist') == set() def test_get_for_unregistered_model(self): self.ir.register('Artist', 'person_id') self.ir.unregister('Artist', 'person_id') assert self.ir.get_for_model('Artist') == set() def test_get_all(self): self.ir.register('Artist', 'person_id') assert self.ir.all() == defaultdict(set, Artist=set(['person_id'])) def test_clear(self): self.ir.register('Artist', 'person_id') self.ir.clear() assert self.ir._data == defaultdict(set)